From 482d0de1dfd5ed877599c42ef34ed1a71019e653 Mon Sep 17 00:00:00 2001 From: Dirk-jan Date: Sat, 13 Jul 2013 11:30:29 +0200 Subject: [PATCH 01/44] Added SQL_MODE for copy and move operations to prevent import errors --- libraries/operations.lib.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/operations.lib.php b/libraries/operations.lib.php index 3b275f6430..126c835306 100644 --- a/libraries/operations.lib.php +++ b/libraries/operations.lib.php @@ -377,6 +377,11 @@ function PMA_getSqlQueryAndCreateDbBeforeCopy() $GLOBALS['dbi']->query($local_query); $GLOBALS['db'] = $original_db; + // Set the SQL mode to NO_AUTO_VALUE_ON_ZERO to prevent MySQL from creating + // export statements it cannot import + $sql_set_mode = "SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'"; + PMA_DBI_query($sql_set_mode); + // rebuild the database list because PMA_Table::moveCopy // checks in this list if the target db exists $GLOBALS['pma']->databases->build(); From 2e26347e422bc64acedc0f11216e2bcd916dddef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 12 Jul 2013 15:04:19 +0200 Subject: [PATCH 02/44] Translated using Weblate (Uzbek) Currently translated at 49.5% (1291 of 2607) --- po/uz.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/po/uz.po b/po/uz.po index 5ae342cf85..0fec9a8972 100644 --- a/po/uz.po +++ b/po/uz.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.0.5-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-06-24 10:43+0200\n" -"PO-Revision-Date: 2013-04-25 15:48+0200\n" +"PO-Revision-Date: 2013-07-12 15:04+0200\n" "Last-Translator: Michal Čihař \n" "Language-Team: Uzbek \n" "Language: uz\n" @@ -105,7 +105,7 @@ msgid "" "for more information." msgstr "" "Ушбу тизимда %s файли мавжуд эмас, мархамат, қўшимча маълумотларни олиш учун " -"www.phpmyadmin.net сайтига ташриф буюринг" +"www.phpmyadmin.net сайтига ташриф буюринг." #: db_create.php:74 #, php-format From 65240d5c0cd030a7943e920c1f7463ab165da97a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 12 Jul 2013 15:38:05 +0200 Subject: [PATCH 03/44] Translated using Weblate (Basque) Currently translated at 22.7% (592 of 2607) --- po/eu.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/po/eu.po b/po/eu.po index 3b62b09785..fbeb3ffcce 100644 --- a/po/eu.po +++ b/po/eu.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.0.5-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-06-24 10:43+0200\n" -"PO-Revision-Date: 2013-04-25 15:47+0200\n" +"PO-Revision-Date: 2013-07-12 15:38+0200\n" "Last-Translator: Michal Čihař \n" "Language-Team: Basque \n" "Language: eu\n" @@ -7798,7 +7798,7 @@ msgstr "" #: libraries/plugins/auth/AuthenticationCookie.class.php:201 msgid "Server:" -msgstr "Zerbitzaria" +msgstr "Zerbitzaria:" #: libraries/plugins/auth/AuthenticationCookie.class.php:213 msgid "Username:" From 0f766a837ec36d94cb9979a99cfbd0ab9d8ee64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 12 Jul 2013 15:45:48 +0200 Subject: [PATCH 04/44] Translated using Weblate (Breton) Currently translated at 26.4% (689 of 2607) --- po/br.po | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/po/br.po b/po/br.po index 868dc834a7..d7f38b724e 100644 --- a/po/br.po +++ b/po/br.po @@ -8,16 +8,15 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.0.5-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-06-24 10:43+0200\n" -"PO-Revision-Date: 2012-11-05 10:16+0200\n" +"PO-Revision-Date: 2013-07-12 15:45+0200\n" "Last-Translator: Michal Čihař \n" -"Language-Team: Breton \n" +"Language-Team: Breton \n" "Language: br\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 1.3-dev\n" +"X-Generator: Weblate 1.6-dev\n" #: browse_foreigners.php:51 browse_foreigners.php:75 js/messages.php:344 #: libraries/DisplayResults.class.php:813 @@ -901,7 +900,7 @@ msgstr "" #: js/messages.php:27 libraries/import.lib.php:118 sql.php:342 msgid "\"DROP DATABASE\" statements are disabled." -msgstr "Diweredekaet eo an urzhad ''DROP DATABASE'" +msgstr "Diweredekaet eo an urzhad ''DROP DATABASE'." #: js/messages.php:30 #, fuzzy, php-format @@ -1992,7 +1991,7 @@ msgstr "" #. l10n: Latest available phpMyAdmin version #: js/messages.php:381 msgid ", latest stable version:" -msgstr ", stumm stabil diwezhañ" +msgstr ", stumm stabil diwezhañ :" #: js/messages.php:382 msgid "up to date" @@ -2406,7 +2405,7 @@ msgstr "Kemmañ" #: libraries/DBQbe.class.php:1322 #, php-format msgid "SQL query on database %s:" -msgstr "Reked SQL ouzh an diaz roadennoù %s: " +msgstr "Reked SQL ouzh an diaz roadennoù %s :" #: libraries/DBQbe.class.php:1336 libraries/Util.class.php:1287 msgid "Submit Query" @@ -2477,7 +2476,7 @@ msgstr "Klask en diaz roadennoù" #: libraries/DbSearch.class.php:386 msgid "Words or values to search for (wildcard: \"%\"):" -msgstr "Gerioù pe dalvoudoù da glask (Joker: \"%\"):" +msgstr "Gerioù pe dalvoudoù da glask (Joker: \"%\") :" #: libraries/DbSearch.class.php:395 msgid "Find:" @@ -2489,7 +2488,7 @@ msgstr "Dispartiet e vez ar gerioù gant un esaouenn (\" \")." #: libraries/DbSearch.class.php:419 msgid "Inside tables:" -msgstr "E diabarzh an taolennoù" +msgstr "E diabarzh an taolennoù :" #: libraries/DbSearch.class.php:445 msgid "Inside column:" @@ -3723,7 +3722,7 @@ msgstr "Klikañ evit gwintañ" #: libraries/Util.class.php:3379 libraries/sql_query_form.lib.php:461 #: prefs_manage.php:242 msgid "Browse your computer:" -msgstr "Furchal en hoc'h urzhiataer" +msgstr "Furchal en hoc'h urzhiataer :" #: libraries/Util.class.php:3404 #, php-format @@ -3837,7 +3836,7 @@ msgstr "Anv ostiz direizh evit ar servijer %1$s. Gwiriit ar c'hefluniadur." #: libraries/common.inc.php:854 msgid "Invalid authentication method set in configuration:" -msgstr "Termenet ez eus bet c'hefluniadur un hentenn dilesa direizh." +msgstr "Termenet ez eus bet c'hefluniadur un hentenn dilesa direizh :" #: libraries/common.inc.php:976 #, php-format From 5f0a9873625cc93b2132cf7998f0560297d100ec Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Mon, 15 Jul 2013 10:30:53 +0800 Subject: [PATCH 05/44] add unit test case for PMA_Table* --- test/classes/PMA_TableSearch_test.php | 107 ++++++++++++ test/classes/PMA_Table_test.php | 225 +++++++++++++++++++++----- 2 files changed, 295 insertions(+), 37 deletions(-) create mode 100644 test/classes/PMA_TableSearch_test.php diff --git a/test/classes/PMA_TableSearch_test.php b/test/classes/PMA_TableSearch_test.php new file mode 100644 index 0000000000..b1f683044c --- /dev/null +++ b/test/classes/PMA_TableSearch_test.php @@ -0,0 +1,107 @@ +getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $columns =array( + array( + 'Field' => 'Field1', + 'Type' => 'Type1', + 'Null' => 'Null1', + 'Collation' => 'Collation1', + ), + array( + 'Field' => 'Field2', + 'Type' => 'Type2', + 'Null' => 'Null2', + 'Collation' => 'Collation2', + ) + ); + $dbi->expects($this->any())->method('getColumns') + ->will($this->returnValue($columns)); + + $show_create_table = "CREATE TABLE `pma_bookmark` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `dbase` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', + `user` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', + `label` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '', + `query` text COLLATE utf8_bin NOT NULL, + PRIMARY KEY (`id`), + KEY `foreign_field` (`foreign_db`,`foreign_table`) + ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Bookmarks'"; + + $dbi->expects($this->any())->method('fetchValue') + ->will($this->returnValue($show_create_table)); + + $GLOBALS['dbi'] = $dbi; + } + + /** + * tearDown function for test cases + * + * @access protected + * @return void + */ + protected function tearDown() + { + + } + + /** + * Test for __construct + * + * @return void + */ + public function testConstruct() + { + $tableSearch = new PMA_TableSearch("PMA", "PMA_BookMark", "normal"); + $columNames = $tableSearch->getColumnNames(); + $this->assertEquals( + 'Field1', + $columNames[0] + ); + $this->assertEquals( + 'Field2', + $columNames[1] + ); + } +} +?> diff --git a/test/classes/PMA_Table_test.php b/test/classes/PMA_Table_test.php index 2664828f4e..15802eeb93 100644 --- a/test/classes/PMA_Table_test.php +++ b/test/classes/PMA_Table_test.php @@ -1,4 +1,5 @@ getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $sql_isView_true = "SELECT TABLE_NAME + FROM information_schema.VIEWS + WHERE TABLE_SCHEMA = 'PMA' + AND TABLE_NAME = 'PMA_BookMark'"; + + $sql_isView_false = "SELECT TABLE_NAME + FROM information_schema.VIEWS + WHERE TABLE_SCHEMA = 'PMA' + AND TABLE_NAME = 'PMA_BookMark_2'"; + + $sql_isUpdatableView_true = "SELECT TABLE_NAME + FROM information_schema.VIEWS + WHERE TABLE_SCHEMA = 'PMA' + AND TABLE_NAME = 'PMA_BookMark' + AND IS_UPDATABLE = 'YES'"; + + $sql_isUpdatableView_false = "SELECT TABLE_NAME + FROM information_schema.VIEWS + WHERE TABLE_SCHEMA = 'PMA' + AND TABLE_NAME = 'PMA_BookMark_2' + AND IS_UPDATABLE = 'YES'"; + + $sql_analyzeStructure_true = "SELECT COLUMN_NAME, DATA_TYPE + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = 'PMA' + AND TABLE_NAME = 'PMA_BookMark'"; + + $fetchResult = array( + array( + $sql_isView_true, + null, + null, + null, + 0, + true + ), + array( + $sql_isView_false, + null, + null, + null, + 0, + false + ), + array( + $sql_isUpdatableView_true, + null, + null, + null, + 0, + true + ), + array( + $sql_isUpdatableView_false, + null, + null, + null, + 0, + false + ), + array( + $sql_analyzeStructure_true, + null, + null, + null, + 0, + array( + array('COLUMN_NAME'=>'COLUMN_NAME', 'DATA_TYPE'=>'DATA_TYPE') + ) + ), + ); + + $dbi = $this->getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $dbi->expects($this->any())->method('fetchResult') + ->will($this->returnValueMap($fetchResult)); + + $GLOBALS['dbi'] = $dbi; } /** - * Test object creating + * tearDown function for test cases * + * @access protected * @return void */ + protected function tearDown() + { + + } + public function testCreate() { $table = new PMA_Table('table1', 'pma_test'); @@ -57,17 +150,103 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase } /** - * Test renaming + * Test for constructor * * @return void */ - public function testRename() + public function testConstruct() { - $table = new PMA_Table('table1', 'pma_test'); - $table->rename('table3'); - $this->assertEquals('table3', $table->getName()); + $table = new PMA_Table("PMA_BookMark", "PMA"); + $this->assertEquals( + 'PMA_BookMark', + $table->__toString() + ); + $this->assertEquals( + 'PMA_BookMark', + $table->getName() + ); + $this->assertEquals( + 'PMA', + $table->getDbName() + ); + $this->assertEquals( + 'PMA.PMA_BookMark', + $table->getFullName() + ); } + /** + * Test for isView + * + * @return void + */ + public function testIsView() + { + $this->assertEquals( + false, + PMA_Table::isView() + ); + + //validate that it is the same as DBI fetchResult + $this->assertEquals( + true, + PMA_Table::isView('PMA', 'PMA_BookMark') + ); + $this->assertEquals( + false, + PMA_Table::isView('PMA', 'PMA_BookMark_2') + ); + } + + /** + * Test for isUpdatableView + * + * @return void + */ + public function testIsUpdatableView() + { + $this->assertEquals( + false, + PMA_Table::isUpdatableView() + ); + + //validate that it is the same as DBI fetchResult + $this->assertEquals( + true, + PMA_Table::isUpdatableView('PMA', 'PMA_BookMark') + ); + $this->assertEquals( + false, + PMA_Table::isUpdatableView('PMA', 'PMA_BookMark_2') + ); + } + + /** + * Test for analyzeStructure + * + * @return void + */ + public function testAnalyzeStructure() + { + $this->assertEquals( + false, + PMA_Table::analyzeStructure() + ); + + //validate that it is the same as DBI fetchResult + $show_create_table = PMA_Table::analyzeStructure('PMA', 'PMA_BookMark'); + $this->assertEquals( + array('type'=>'DATA_TYPE'), + $show_create_table[0]['create_table_fields']['COLUMN_NAME'] + ); + } + + /** + * Test object creating + * + * @return void + */ + /** * Test Set & Get * @@ -88,34 +267,6 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase ); } - /** - * Test getting columns - * - * @return void - */ - public function testColumns() - { - $table = new PMA_Table('table1', 'pma_test'); - $this->assertEquals( - array('`pma_test`.`table1`.`i`', '`pma_test`.`table1`.`o`'), - $table->getColumns() - ); - } - - /** - * Test getting unique columns - * - * @return void - */ - public function testUniqueColumns() - { - $table = new PMA_Table('table1', 'pma_test'); - $this->assertEquals( - array(), - $table->getUniqueColumns() - ); - } - /** * Test name validation * @@ -149,4 +300,4 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase ); } } - +?> From 7cf5cc0d4c6b3bdf4dd96fc68788ae01ba1c4940 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Mon, 15 Jul 2013 10:42:31 +0800 Subject: [PATCH 06/44] make better diff --- test/classes/PMA_Table_test.php | 124 +++++++++++++++++--------------- 1 file changed, 65 insertions(+), 59 deletions(-) diff --git a/test/classes/PMA_Table_test.php b/test/classes/PMA_Table_test.php index 15802eeb93..b525f44571 100644 --- a/test/classes/PMA_Table_test.php +++ b/test/classes/PMA_Table_test.php @@ -142,7 +142,12 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase { } - + + /** + * Test object creating + * + * @return void + */ public function testCreate() { $table = new PMA_Table('table1', 'pma_test'); @@ -175,6 +180,65 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase ); } + /** + * Test object creating + * + * @return void + */ + + /** + * Test Set & Get + * + * @return void + */ + public function testSetAndGet() + { + $table = new PMA_Table('table1', 'pma_test'); + $table->set('production', 'Phpmyadmin'); + $table->set('db', 'mysql'); + $this->assertEquals( + "Phpmyadmin", + $table->get("production") + ); + $this->assertEquals( + "mysql", + $table->get("db") + ); + } + + /** + * Test name validation + * + * @param string $name name to test + * @param boolena $result expected result + * + * @return void + * + * @dataProvider dataValidateName + */ + public function testValidateName($name, $result) + { + $this->assertEquals( + $result, + PMA_Table::isValidName($name) + ); + } + + /** + * Data provider for name validation + * + * @return array with test data + */ + public function dataValidateName() + { + return array( + array('test', true), + array('te/st', false), + array('te.st', false), + array('te\\st', false), + ); + } + /** * Test for isView * @@ -241,63 +305,5 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase ); } - /** - * Test object creating - * - * @return void - */ - - /** - * Test Set & Get - * - * @return void - */ - public function testSetAndGet() - { - $table = new PMA_Table('table1', 'pma_test'); - $table->set('production', 'Phpmyadmin'); - $table->set('db', 'mysql'); - $this->assertEquals( - "Phpmyadmin", - $table->get("production") - ); - $this->assertEquals( - "mysql", - $table->get("db") - ); - } - - /** - * Test name validation - * - * @param string $name name to test - * @param boolena $result expected result - * - * @return void - * - * @dataProvider dataValidateName - */ - public function testValidateName($name, $result) - { - $this->assertEquals( - $result, - PMA_Table::isValidName($name) - ); - } - - /** - * Data provider for name validation - * - * @return array with test data - */ - public function dataValidateName() - { - return array( - array('test', true), - array('te/st', false), - array('te.st', false), - array('te\\st', false), - ); - } } ?> From 253d59919a4cba9fd597d57b0c5093745c489427 Mon Sep 17 00:00:00 2001 From: xmujay Date: Mon, 15 Jul 2013 13:26:55 +0800 Subject: [PATCH 07/44] refactor server_status_advisor.php: moving functions to server_status_advisor.lib.php --- libraries/server_status_advisor.lib.php | 70 +++++++++++++++++++++++++ server_status_advisor.php | 56 ++------------------ 2 files changed, 73 insertions(+), 53 deletions(-) create mode 100644 libraries/server_status_advisor.lib.php diff --git a/libraries/server_status_advisor.lib.php b/libraries/server_status_advisor.lib.php new file mode 100644 index 0000000000..5d38cb9534 --- /dev/null +++ b/libraries/server_status_advisor.lib.php @@ -0,0 +1,70 @@ +'; + $output .= PMA_Util::getIcon('b_help.png', __('Instructions')); + $output .= ''; + $output .= '
'; + $output .= ''; + $output .= ''; + + return $output; +} + +?> + + diff --git a/server_status_advisor.php b/server_status_advisor.php index 219a4ee27a..6f882033cc 100644 --- a/server_status_advisor.php +++ b/server_status_advisor.php @@ -9,6 +9,8 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/Advisor.class.php'; require_once 'libraries/ServerStatusData.class.php'; +require_once 'libraries/server_status_advisor.lib.php'; + if (PMA_DRIZZLE) { $server_master_status = false; $server_slave_status = false; @@ -28,62 +30,10 @@ $scripts->addFile('server_status_advisor.js'); */ $response->addHTML('
'); $response->addHTML($ServerStatusData->getMenuHtml()); -$response->addHTML(PMA_getAdvisorHtml()); +$response->addHTML(PMA_getHtmlForAdvisor()); $response->addHTML('
'); exit; -/** - * Returns html with Advisor - * - * @return string - */ -function PMA_getAdvisorHtml() -{ - $output = ''; - $output .= PMA_Util::getIcon('b_help.png', __('Instructions')); - $output .= ''; - $output .= '
'; - $output .= ''; - $output .= ''; - - return $output; -} ?> From 7873d84c709637689b36cec3125dd549b4c3289a Mon Sep 17 00:00:00 2001 From: Panagiotis Papazoglou Date: Mon, 15 Jul 2013 07:44:31 +0200 Subject: [PATCH 08/44] Translated using Weblate (Greek) Currently translated at 100.0% (2680 of 2680) --- po/el.po | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/po/el.po b/po/el.po index 3942904d67..ac63bf55aa 100644 --- a/po/el.po +++ b/po/el.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-07-12 16:06+0200\n" -"PO-Revision-Date: 2013-07-04 19:42+0200\n" +"PO-Revision-Date: 2013-07-15 07:44+0200\n" "Last-Translator: Panagiotis Papazoglou \n" "Language-Team: Greek \n" "Language: el\n" @@ -3312,10 +3312,9 @@ msgid "Reset zoom" msgstr "Επανφορά εστίασης" #: libraries/TableSearch.class.php:1281 -#, fuzzy #| msgid "Replace with" msgid "Replace with:" -msgstr "Αντικατάσταση με" +msgstr "Αντικατάσταση με:" #: libraries/TableSearch.class.php:1341 msgid "Find and replace - preview" From 493c23d18fdb926d3e46ed0d6a38eaa85891513b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Jul 2013 10:42:02 +0200 Subject: [PATCH 09/44] Add shared code to setup header testing using runkit --- test/bootstrap-dist.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/bootstrap-dist.php b/test/bootstrap-dist.php index cfcacc3404..0edf05e329 100644 --- a/test/bootstrap-dist.php +++ b/test/bootstrap-dist.php @@ -34,4 +34,41 @@ $_SESSION[' PMA_token '] = 'token'; $GLOBALS['lang'] = 'en'; $GLOBALS['is_ajax_request'] = false; + +define('PMA_HAS_RUNKIT', function_exists('runkit_constant_redefine')); +$GLOBALS['runkit_internal_override'] = ini_get('runkit.internal_override'); + + +/** + * Function to emulate headers() function by storing headers in GLOBAL array. + */ +function test_header($string, $replace = true, $http_response_code = 200) +{ + if (! isset($GLOBALS['header'])) { + $GLOBALS['header'] = array(); + } + + $GLOBALS['header'][] = $string; +} + +/** + * Function to emulate headers_hest. + */ +function test_headers_sent() +{ + return false; +} + +if (PMA_HAS_RUNKIT && $GLOBALS['runkit_internal_override']) { + echo "Enabling headers testing...\n"; + runkit_function_rename('header', 'test_header_override'); + runkit_function_rename('headers_sent', 'test_headers_sent_override'); + runkit_function_rename('test_header', 'header'); + runkit_function_rename('test_headers_sent', 'headers_sent'); + define('PMA_TEST_HEADERS', true); +} else { + echo "No headers testing.\n"; + echo "Please install runkit and enable runkit.internal_override!\n"; +} + ?> From a2e9ee199ed449d7ed1792bc537a0df1428bfe39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Jul 2013 10:42:41 +0200 Subject: [PATCH 10/44] Migrate PMA_sendHeaderLocation testing to shared header testing code --- .../core/PMA_headerLocation_test.php | 136 +++--------------- 1 file changed, 17 insertions(+), 119 deletions(-) diff --git a/test/libraries/core/PMA_headerLocation_test.php b/test/libraries/core/PMA_headerLocation_test.php index 61069caf6f..47d1127b50 100644 --- a/test/libraries/core/PMA_headerLocation_test.php +++ b/test/libraries/core/PMA_headerLocation_test.php @@ -50,110 +50,12 @@ class PMA_HeaderLocation_Test extends PHPUnit_Framework_TestCase protected $runkitExt; protected $apdExt; - public function __construct() - { - parent::__construct(); - $this->runkitExt = false; - if (function_exists("runkit_constant_redefine")) { - $this->runkitExt = true; - } - - $this->apdExt = false; - if (function_exists("rename_function")) { - $this->apdExt = true; - } - - if ($this->apdExt && !$GLOBALS['test_header']) { - - /* - * using apd extension to overriding header and headers_sent - * functions for test purposes - */ - $GLOBALS['test_header'] = 1; - - /* - * rename_function() of header and headers_sent may cause CLI error - * report in Windows XP - */ - rename_function('header', 'test_header'); - rename_function('headers_sent', 'test_headers_sent'); - - /* - * solution from: - * http://unixwars.com/2008/11/29/override_function-in-php/ - * to overriding more than one function - */ - - $substs = array( - 'header' => - 'if (isset($GLOBALS["header"])) {' - . '$GLOBALS["header"] .= $a;' - . '} else {' - . '$GLOBALS["header"] = $a;' - . '}', - 'headers_sent' => 'return false;' - ); - - $args = array( - 'header' => '$a', - 'headers_sent' => '' - ); - - foreach ($substs as $func => $ren_func) { - if (function_exists("__overridden__")) { - rename_function( - "__overridden__", - str_replace( - array('.', ' '), - array('', ''), - microtime() - ) - ); - } - override_function($func, $args[$func], $substs[$func]); - rename_function( - "__overridden__", - str_replace(array('.', ' '), array('', ''), microtime()) - ); - } - - } - } - - public function __destruct() - { - /* - * rename_function may causes CLI error report in Windows XP, but - * nothing more happen - */ - - if ($this->apdExt && $GLOBALS['test_header']) { - $GLOBALS['test_header'] = 0; - - rename_function( - 'header', - 'header' . str_replace( - array('.', ' '), array('', ''), microtime() - ) - ); - rename_function( - 'headers_sent', - 'headers_sent' . str_replace( - array('.', ' '), array('', ''), microtime() - ) - ); - - rename_function('test_header', 'header'); - rename_function('test_headers_sent', 'headers_sent'); - } - } - public function setUp() { //session_start(); // cleaning constants - if ($this->runkitExt) { + if (PMA_HAS_RUNKIT) { $this->oldIISvalue = 'non-defined'; @@ -189,7 +91,7 @@ class PMA_HeaderLocation_Test extends PHPUnit_Framework_TestCase //session_destroy(); // cleaning constants - if ($this->runkitExt) { + if (PMA_HAS_RUNKIT) { if ($this->oldIISvalue != 'non-defined') { runkit_constant_redefine('PMA_IS_IIS', $this->oldIISvalue); @@ -203,23 +105,19 @@ class PMA_HeaderLocation_Test extends PHPUnit_Framework_TestCase runkit_constant_remove('SID'); } } - - if ($this->apdExt) { - unset($GLOBALS['header']); - } } public function testSendHeaderLocationWithSidUrlWithQuestionMark() { - if ($this->runkitExt && $this->apdExt) { + if (defined('PMA_TEST_HEADERS')) { runkit_constant_redefine('SID', md5('test_hash')); $testUri = 'http://testurl.com/test.php?test=test'; $separator = PMA_get_arg_separator(); - $header = 'Location: ' . $testUri . $separator . SID; + $header = array('Location: ' . $testUri . $separator . SID); /* sets $GLOBALS['header'] */ PMA_sendHeaderLocation($testUri); @@ -228,7 +126,7 @@ class PMA_HeaderLocation_Test extends PHPUnit_Framework_TestCase } else { $this->markTestSkipped( - 'Cannot redefine constant/function - missing APD or/and runkit extension' + 'Cannot redefine constant/function - missing runkit extension' ); } @@ -236,74 +134,74 @@ class PMA_HeaderLocation_Test extends PHPUnit_Framework_TestCase public function testSendHeaderLocationWithSidUrlWithoutQuestionMark() { - if ($this->runkitExt && $this->apdExt) { + if (defined('PMA_TEST_HEADERS')) { runkit_constant_redefine('SID', md5('test_hash')); $testUri = 'http://testurl.com/test.php'; $separator = PMA_get_arg_separator(); - $header = 'Location: ' . $testUri . '?' . SID; + $header = array('Location: ' . $testUri . '?' . SID); PMA_sendHeaderLocation($testUri); // sets $GLOBALS['header'] $this->assertEquals($header, $GLOBALS['header']); } else { - $this->markTestSkipped('Cannot redefine constant/function - missing APD or/and runkit extension'); + $this->markTestSkipped('Cannot redefine constant/function - missing runkit extension'); } } public function testSendHeaderLocationWithoutSidWithIis() { - if ($this->runkitExt && $this->apdExt) { + if (defined('PMA_TEST_HEADERS')) { runkit_constant_redefine('PMA_IS_IIS', true); $testUri = 'http://testurl.com/test.php'; $separator = PMA_get_arg_separator(); - $header = 'Location: ' . $testUri; + $header = array('Location: ' . $testUri); PMA_sendHeaderLocation($testUri); // sets $GLOBALS['header'] $this->assertEquals($header, $GLOBALS['header']); //reset $GLOBALS['header'] for the next assertion unset($GLOBALS['header']); - $header = 'Refresh: 0; ' . $testUri; + $header = array('Refresh: 0; ' . $testUri); PMA_sendHeaderLocation($testUri, true); // sets $GLOBALS['header'] $this->assertEquals($header, $GLOBALS['header']); } else { - $this->markTestSkipped('Cannot redefine constant/function - missing APD or/and runkit extension'); + $this->markTestSkipped('Cannot redefine constant/function - missing runkit extension'); } } public function testSendHeaderLocationWithoutSidWithoutIis() { - if ($this->apdExt) { + if (defined('PMA_TEST_HEADERS')) { $testUri = 'http://testurl.com/test.php'; - $header = 'Location: ' . $testUri; + $header = array('Location: ' . $testUri); PMA_sendHeaderLocation($testUri); // sets $GLOBALS['header'] $this->assertEquals($header, $GLOBALS['header']); } else { - $this->markTestSkipped('Cannot redefine constant/function - missing APD or/and runkit extension'); + $this->markTestSkipped('Cannot redefine constant/function - missing runkit extension'); } } public function testSendHeaderLocationIisLongUri() { - if (defined('PMA_IS_IIS') && $this->runkitExt) { + if (defined('PMA_IS_IIS') && PMA_HAS_RUNKIT) { runkit_constant_redefine('PMA_IS_IIS', true); } elseif (!defined('PMA_IS_IIS')) { define('PMA_IS_IIS', true); } else { - $this->markTestSkipped('Cannot redefine constant/function - missing APD or/and runkit extension'); + $this->markTestSkipped('Cannot redefine constant/function - missing runkit extension'); } // over 600 chars From 870fc8b27dd871158aea4ebdc30254c07202d7a0 Mon Sep 17 00:00:00 2001 From: Panagiotis Papazoglou Date: Mon, 15 Jul 2013 07:46:54 +0200 Subject: [PATCH 11/44] Translated using Weblate (Greek) Currently translated at 100.0% (2680 of 2680) --- po/el.po | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/po/el.po b/po/el.po index ac63bf55aa..f57c72320d 100644 --- a/po/el.po +++ b/po/el.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-07-12 16:06+0200\n" -"PO-Revision-Date: 2013-07-15 07:44+0200\n" +"PO-Revision-Date: 2013-07-15 07:46+0200\n" "Last-Translator: Panagiotis Papazoglou \n" "Language-Team: Greek \n" "Language: el\n" @@ -1672,7 +1672,7 @@ msgstr "Προσθήκη %d τιμής(ών)" #: js/messages.php:259 msgid "" "Note: If the file contains multiple tables, they will be combined into one." -msgstr "Σημείωση: Αν το αρχείο περιέχει πολλούς πίνακες, θα ενωθουν σε έναν" +msgstr "Σημείωση: Αν το αρχείο περιέχει πολλούς πίνακες, θα ενωθουν σε έναν." #: js/messages.php:262 msgid "Hide query box" @@ -2849,7 +2849,7 @@ msgstr "Το πρωτεύον κλειδί διεγράφη" #: libraries/Index.class.php:608 #, php-format msgid "Index %s has been dropped." -msgstr "Το ευρετήριο %s διεγράφη" +msgstr "Το ευρετήριο %s έχει διαγραφεί." #: libraries/Index.class.php:731 #, php-format @@ -3826,8 +3826,7 @@ msgstr "Επιλογή από το φάκελο αποστολής του δια #: libraries/Util.class.php:3441 libraries/insert_edit.lib.php:1183 #: libraries/sql_query_form.lib.php:483 msgid "The directory you set for upload work cannot be reached." -msgstr "" -"Ο υποκατάλογος που ορίσατε για την αποθήκευση αρχείων δεν μπόρεσε να βρεθεί" +msgstr "Ο φάκελος που ορίσατε για την αποθήκευση αρχείων δεν μπόρεσε να βρεθεί." #: libraries/Util.class.php:3452 msgid "There are no files to upload" @@ -8013,7 +8012,7 @@ msgstr "" msgid "No activity within %s seconds; please log in again." msgstr "" "Καμιά δραστηριότητα εδώ και %s δευτερόλεπτα τουλάχιστον, για αυτό " -"ξανασυνδεθείτε" +"ξανασυνδεθείτε." #: libraries/plugins/auth/AuthenticationCookie.class.php:667 #: libraries/plugins/auth/AuthenticationCookie.class.php:669 @@ -8037,7 +8036,7 @@ msgstr "Το αρχείο %s δεν περιέχει καμιά ταυτότητ #: libraries/plugins/auth/swekey/swekey.auth.lib.php:176 #: libraries/plugins/auth/swekey/swekey.auth.lib.php:196 msgid "Hardware authentication failed!" -msgstr "Η επικύρωση του υλικού απέτυχε" +msgstr "Η επικύρωση του υλικού απέτυχε!" #: libraries/plugins/auth/swekey/swekey.auth.lib.php:183 msgid "No valid authentication key plugged" @@ -11278,9 +11277,9 @@ msgid "" "There seems to be an error in your SQL query. The MySQL server error output " "below, if there is any, may also help you in diagnosing the problem." msgstr "" -"Φαίνεται να υπάρχει ένα λάθος στο ερώτημά σας. Το παρακάτω λάθος διακομιστή " -"MySQL, εάν υπάρχει κάποιο, μπορεί επίσης να σας βοηθήσει να διαγνώσετε το " -"πρόβλημα" +"Φαίνεται να υπάρχει ένα λάθος στο ερώτημά SQL σας. Το παρακάτω λάθος " +"διακομιστή MySQL, εάν υπάρχει κάποιο, μπορεί επίσης να σας βοηθήσει να " +"διαγνώσετε το πρόβλημα." #: libraries/sqlparser.lib.php:178 msgid "" From 574f520b1a7bc4ae0d94446789cfef51ec66e28c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Jul 2013 10:51:26 +0200 Subject: [PATCH 12/44] Use new shared runkit detection --- test/classes/config/PMA_FormDisplay_test.php | 60 +++++++++--------- test/libraries/PMA_ConfigFile_test.php | 6 +- test/libraries/PMA_FormDisplay_tpl_test.php | 66 ++++++++++---------- test/libraries/PMA_Index_test.php | 2 +- test/libraries/PMA_Tracker_test.php | 8 +-- test/libraries/PMA_mysql_charsets_test.php | 8 +-- test/libraries/PMA_user_preferences_test.php | 50 +++++++-------- test/libraries/common/PMA_whichCrlf_test.php | 11 ++-- 8 files changed, 105 insertions(+), 106 deletions(-) diff --git a/test/classes/config/PMA_FormDisplay_test.php b/test/classes/config/PMA_FormDisplay_test.php index 1e682b22de..51549eb6f9 100644 --- a/test/classes/config/PMA_FormDisplay_test.php +++ b/test/classes/config/PMA_FormDisplay_test.php @@ -41,7 +41,7 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase /** * tearDown for test cases - * + * * @return void */ protected function tearDown() @@ -51,11 +51,11 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase /** * Test for FormDisplay::__constructor - * + * * @return void */ public function testFormDisplayContructor() - { + { $this->assertCount( 5, $this->readAttribute($this->object, '_jsLangStrings') @@ -64,13 +64,13 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase /** * Test for FormDisplay::registerForm - * + * * @return void */ public function testRegisterForm() { $reflection = new \ReflectionClass('FormDisplay'); - + $attrForms = $reflection->getProperty('_forms'); $attrForms->setAccessible(true); @@ -109,7 +109,7 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase /** * Test for FormDisplay::process - * + * * @return void */ public function testProcess() @@ -145,13 +145,13 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase /** * Test for FormDisplay::displayErrors - * + * * @return void */ public function testDisplayErrors() { $reflection = new \ReflectionClass('FormDisplay'); - + $attrIsValidated = $reflection->getProperty('_isValidated'); $attrIsValidated->setAccessible(true); $attrIsValidated->setValue($this->object, true); @@ -192,13 +192,13 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase /** * Test for FormDisplay::fixErrors - * + * * @return void */ public function testFixErrors() { $reflection = new \ReflectionClass('FormDisplay'); - + $attrIsValidated = $reflection->getProperty('_isValidated'); $attrIsValidated->setAccessible(true); $attrIsValidated->setValue($this->object, true); @@ -228,7 +228,7 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase $attrIsValidated->setValue($this->object, $arr); $this->object->fixErrors(); - + $this->assertEquals( array( 'Servers' => array( @@ -243,17 +243,17 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase /** * Test for FormDisplay::_validateSelect - * + * * @return void */ public function testValidateSelect() - { + { $attrValidateSelect = new \ReflectionMethod( 'FormDisplay', '_validateSelect' ); $attrValidateSelect->setAccessible(true); - + $arr = array('foo' => 'var'); $value = 'foo'; $this->assertTrue( @@ -284,7 +284,7 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase array(&$value, $arr) ) ); - + $arr = array('1' => 'foobar'); $value = 0; $this->assertFalse( @@ -297,7 +297,7 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase /** * Test for FormDisplay::hasErrors - * + * * @return void */ public function testHasErrors() @@ -321,7 +321,7 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase /** * Test for FormDisplay::getDocLink - * + * * @return void */ public function testGetDocLink() @@ -346,25 +346,25 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase /** * Test for FormDisplay::getWikiLink - * + * * @return void */ public function testGetWikiLink() { $this->assertEquals( - "./url.php?url=http%3A%2F%2Fwiki.phpmyadmin.net%2Fpma%2FConfig%23" . + "./url.php?url=http%3A%2F%2Fwiki.phpmyadmin.net%2Fpma%2FConfig%23" . "AllowDeny.29&server=0&lang=en&token=token", $this->object->getWikiLink('Servers/1/AllowDeny') ); $this->assertEquals( - "./url.php?url=http%3A%2F%2Fwiki.phpmyadmin.net%2Fpma%2FConfig%23" . + "./url.php?url=http%3A%2F%2Fwiki.phpmyadmin.net%2Fpma%2FConfig%23" . "format_2&server=0&lang=en&token=token", $this->object->getWikiLink('Import/format') ); $this->assertEquals( - "./url.php?url=http%3A%2F%2Fwiki.phpmyadmin.net%2Fpma%2FConfig%23" . + "./url.php?url=http%3A%2F%2Fwiki.phpmyadmin.net%2Fpma%2FConfig%23" . "test&server=0&lang=en&token=token", $this->object->getWikiLink('Export/test') ); @@ -373,7 +373,7 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase /** * Test for FormDisplay::_getOptName - * + * * @return void */ public function testGetOptName() @@ -394,14 +394,14 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase /** * Test for FormDisplay::_loadUserprefsInfo - * + * * @return void */ public function testLoadUserprefsInfo() { $method = new \ReflectionMethod('FormDisplay', '_loadUserprefsInfo'); $method->setAccessible(true); - + $attrUserprefs = new \ReflectionProperty( 'FormDisplay', '_userprefsDisallow' @@ -417,12 +417,12 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase /** * Test for FormDisplay::_setComments - * + * * @return void */ public function testSetComments() { - if (!function_exists('runkit_constant_redefine')) { + if (! PMA_HAS_RUNKIT) { $this->markTestSkipped('Cannot redefine constant'); } @@ -447,11 +447,11 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase } if (!function_exists('recode_string')) { $expect['values']['recode'] .= " (unavailable)"; - $expect['comment'] .= ($expect['comment'] ? ", " : '') . + $expect['comment'] .= ($expect['comment'] ? ", " : '') . '"recode" requires recode extension'; } $expect['comment_warning'] = 1; - + $this->assertEquals( $expect, $opts @@ -531,7 +531,7 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase ); // SQLValidate - + $GLOBALS['cfg']['SQLValidator']['use'] = false; $method->invokeArgs( @@ -555,7 +555,7 @@ class PMA_FormDisplay_Test extends PHPUnit_Framework_TestCase $GLOBALS['cfg']['MaxDbList'] = 10; $GLOBALS['cfg']['MaxTableList'] = 10; $GLOBALS['cfg']['QueryHistoryMax'] = 10; - + $method->invokeArgs( $this->object, array('MaxDbList', &$opts) diff --git a/test/libraries/PMA_ConfigFile_test.php b/test/libraries/PMA_ConfigFile_test.php index 3b6a3df098..096c8f6fa1 100644 --- a/test/libraries/PMA_ConfigFile_test.php +++ b/test/libraries/PMA_ConfigFile_test.php @@ -44,7 +44,7 @@ class PMA_ConfigFile_Test extends PHPUnit_Framework_TestCase unset($_SESSION[$this->readAttribute($this->object, "_id")]); unset($this->object); - + // reset the instance $attr_instance = new ReflectionProperty("ConfigFile", "_instance"); $attr_instance->setAccessible(true); @@ -58,7 +58,7 @@ class PMA_ConfigFile_Test extends PHPUnit_Framework_TestCase * @test */ public function testConfigFileConstructor() - { + { $attr_instance = new ReflectionProperty("ConfigFile", "_instance"); $attr_instance->setAccessible(true); $attr_instance->setValue(null, null); @@ -237,7 +237,7 @@ class PMA_ConfigFile_Test extends PHPUnit_Framework_TestCase */ public function testConfigFileSet() { - if (!function_exists("runkit_constant_redefine")) { + if (! PMA_HAS_RUNKIT) { $this->markTestSkipped("Cannot redefine constant"); } diff --git a/test/libraries/PMA_FormDisplay_tpl_test.php b/test/libraries/PMA_FormDisplay_tpl_test.php index 524c237d61..c9ddc07b80 100644 --- a/test/libraries/PMA_FormDisplay_tpl_test.php +++ b/test/libraries/PMA_FormDisplay_tpl_test.php @@ -24,10 +24,10 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase /** * Return the tag array to be used with assertTag by parsing * a given HTML element - * + * * @param string $elementHTML HTML for element to be parsed * @param array $arr Additional array elements like content, parent - * + * * @return array Tag array to be used with assertTag */ private function _getTagArray($elementHTML, $arr = array()) @@ -51,7 +51,7 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase /** * Test for PMA_displayFormTop() - * + * * @return void */ public function testDisplayFormTop() @@ -64,7 +64,7 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase $this->assertTag( $this->_getTagArray( - '
' ), $result @@ -109,7 +109,7 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase /** * Test for PMA_displayTabsTop() - * + * * @return void */ public function testDisplayTabsTop() @@ -141,7 +141,7 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase /** * Test for PMA_displayFieldsetTop() - * + * * @return void */ public function testDisplayFieldsetTop() @@ -214,12 +214,12 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase /** * Test for PMA_displayInput() - * + * * @return void */ public function testDisplayInput() - { - if (!function_exists('runkit_constant_remove')) { + { + if (! PMA_HAS_RUNKIT) { $this->markTestSkipped('Cannot modify constant'); } @@ -241,7 +241,7 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase 'desc', false, $opts ); $result = ob_get_clean(); - + $this->assertTag( $this->_getTagArray( '' @@ -338,9 +338,9 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase '
e1
', $result ); - + // second case - + define('PMA_SETUP', true); $GLOBALS['_FormDislayGroup'] = 0; $GLOBALS['cfg']['ThemePath'] = 'themePath'; @@ -351,7 +351,7 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase $opts['show_restore_default'] = true; $opts['userprefs_comment'] = 'userprefsComment'; $opts['userprefs_allow'] = true; - + ob_start(); PMA_displayInput( 'test/path', 'testName', 'checkbox', 'val', @@ -447,7 +447,7 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase ), $result ); - + // select case 1 $opts['values_escaped'] = true; $opts['values_disabled'] = array(1, 2); @@ -523,7 +523,7 @@ class PMA_FormDisplay_Tpl_Test extends PHPUnit_Framework_TestCase '', true, $opts ); $result = ob_get_clean(); - + $this->assertTag( $this->_getTagArray( '