From 843de6fdf5ea5a157e43d0e4a4f17db114a9f5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 10:39:57 +0200 Subject: [PATCH 01/13] Fix testcase --- test/classes/Advisor_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/classes/Advisor_test.php b/test/classes/Advisor_test.php index ac43516eb1..2bc0e686c7 100644 --- a/test/classes/Advisor_test.php +++ b/test/classes/Advisor_test.php @@ -33,7 +33,7 @@ class Advisor_test extends PHPUnit_Framework_TestCase public function testParse() { $advisor = new Advisor(); - $parseResult = $this->parseRulesFile(); + $parseResult = $advisor->parseRulesFile(); $this->assertEquals($parseResult['errors'], array()); } } From 72f9042b9ae715b912057934bdbc061a2444ff65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 10:43:21 +0200 Subject: [PATCH 02/13] Coding style --- libraries/Advisor.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php index ca9fb6f61f..bf4fd41b73 100644 --- a/libraries/Advisor.class.php +++ b/libraries/Advisor.class.php @@ -69,9 +69,11 @@ class Advisor $this->variables['value'] = $value; try { - if($this->ruleExprEvaluate($rule['test'])) + if ($this->ruleExprEvaluate($rule['test'])) { $this->addRule('fired', $rule); - else $this->addRule('notfired', $rule); + } else { + $this->addRule('notfired', $rule); + } } catch(Exception $e) { $this->runResult['errors'][] = 'Failed running test for rule \''.$rule['name'].'\'. PHP threw following error: '.$e->getMessage(); } From 9889e68133fa209d961d1aea8a9cd51451af6f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 10:54:53 +0200 Subject: [PATCH 03/13] Add testcase for adding rules --- test/classes/Advisor_test.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/classes/Advisor_test.php b/test/classes/Advisor_test.php index 2bc0e686c7..a1363d2ba6 100644 --- a/test/classes/Advisor_test.php +++ b/test/classes/Advisor_test.php @@ -10,6 +10,9 @@ * Include to test. */ require_once 'libraries/Advisor.class.php'; +require_once 'libraries/php-gettext/gettext.inc'; +require_once 'libraries/url_generating.lib.php'; +require_once 'libraries/core.lib.php'; class Advisor_test extends PHPUnit_Framework_TestCase { @@ -36,5 +39,29 @@ class Advisor_test extends PHPUnit_Framework_TestCase $parseResult = $advisor->parseRulesFile(); $this->assertEquals($parseResult['errors'], array()); } + + /** + * @depends testParse + * @dataProvider rulesProvider + */ + public function testAddRule($rule, $expected) + { + $advisor = new Advisor(); + $parseResult = $advisor->parseRulesFile(); + $this->assertEquals($parseResult['errors'], array()); + $this->variables['value'] = 0; + $advisor->addRule('fired', $rule); + $this->assertEquals($advisor->runResult['fired'], array($expected)); + } + + public function rulesProvider() + { + return array( + array( + array('justification' => 'foo', 'name' => 'name', 'issue' => 'issue', 'recommendation' => 'Recommend'), + array('justification' => 'foo', 'name' => 'name', 'issue' => 'issue', 'recommendation' => 'Recommend'), + ), + ); + } } ?> From e4c101c4d64ca3d63601c84b26b4c1be82f57f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 11:02:39 +0200 Subject: [PATCH 04/13] Add more cases for adding rules --- test/classes/Advisor_test.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/test/classes/Advisor_test.php b/test/classes/Advisor_test.php index a1363d2ba6..24b8fe688f 100644 --- a/test/classes/Advisor_test.php +++ b/test/classes/Advisor_test.php @@ -16,6 +16,11 @@ require_once 'libraries/core.lib.php'; class Advisor_test extends PHPUnit_Framework_TestCase { + public function setup() + { + $_SESSION[' PMA_token '] = 'token'; + } + /** * @dataProvider escapeStrings */ @@ -49,8 +54,11 @@ class Advisor_test extends PHPUnit_Framework_TestCase $advisor = new Advisor(); $parseResult = $advisor->parseRulesFile(); $this->assertEquals($parseResult['errors'], array()); - $this->variables['value'] = 0; + $advisor->variables['value'] = 0; $advisor->addRule('fired', $rule); + if (isset($advisor->runResult['errors'])) { + $this->assertEquals($advisor->runResult['errors'], array()); + } $this->assertEquals($advisor->runResult['fired'], array($expected)); } @@ -58,8 +66,20 @@ class Advisor_test extends PHPUnit_Framework_TestCase { return array( array( - array('justification' => 'foo', 'name' => 'name', 'issue' => 'issue', 'recommendation' => 'Recommend'), - array('justification' => 'foo', 'name' => 'name', 'issue' => 'issue', 'recommendation' => 'Recommend'), + array('justification' => 'foo', 'name' => 'Basic', 'issue' => 'issue', 'recommendation' => 'Recommend'), + array('justification' => 'foo', 'name' => 'Basic', 'issue' => 'issue', 'recommendation' => 'Recommend'), + ), + array( + array('justification' => 'foo', 'name' => 'Variable', 'issue' => 'issue', 'recommendation' => 'Recommend {status_var}'), + array('justification' => 'foo', 'name' => 'Variable', 'issue' => 'issue', 'recommendation' => 'Recommend status_var'), + ), + array( + array('justification' => '%s foo | value', 'name' => 'Format', 'issue' => 'issue', 'recommendation' => 'Recommend'), + array('justification' => '0 foo', 'name' => 'Format', 'issue' => 'issue', 'recommendation' => 'Recommend'), + ), + array( + array('justification' => '%s% foo | value', 'name' => 'Percent', 'issue' => 'issue', 'recommendation' => 'Recommend'), + array('justification' => '0% foo', 'name' => 'Percent', 'issue' => 'issue', 'recommendation' => 'Recommend'), ), ); } From 83b859f679a36e8873477c45490dd46eb923cf5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 11:07:07 +0200 Subject: [PATCH 05/13] Add test for quotes handling --- test/classes/Advisor_test.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/classes/Advisor_test.php b/test/classes/Advisor_test.php index 24b8fe688f..4f30f57197 100644 --- a/test/classes/Advisor_test.php +++ b/test/classes/Advisor_test.php @@ -81,6 +81,10 @@ class Advisor_test extends PHPUnit_Framework_TestCase array('justification' => '%s% foo | value', 'name' => 'Percent', 'issue' => 'issue', 'recommendation' => 'Recommend'), array('justification' => '0% foo', 'name' => 'Percent', 'issue' => 'issue', 'recommendation' => 'Recommend'), ), + array( + array('justification' => '"\'foo', 'name' => 'Quotes', 'issue' => 'issue', 'recommendation' => 'Recommend"\''), + array('justification' => '"\'foo', 'name' => 'Quotes', 'issue' => 'issue', 'recommendation' => 'Recommend"\''), + ), ); } } From 670b6ea38b626750bd7ceaee393542e461d04c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 11:18:25 +0200 Subject: [PATCH 06/13] Fix test with lang set --- test/classes/Advisor_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/classes/Advisor_test.php b/test/classes/Advisor_test.php index 4f30f57197..d5d9dda81f 100644 --- a/test/classes/Advisor_test.php +++ b/test/classes/Advisor_test.php @@ -19,6 +19,7 @@ class Advisor_test extends PHPUnit_Framework_TestCase public function setup() { $_SESSION[' PMA_token '] = 'token'; + $GLOBALS['lang'] = 'en'; } /** @@ -71,7 +72,7 @@ class Advisor_test extends PHPUnit_Framework_TestCase ), array( array('justification' => 'foo', 'name' => 'Variable', 'issue' => 'issue', 'recommendation' => 'Recommend {status_var}'), - array('justification' => 'foo', 'name' => 'Variable', 'issue' => 'issue', 'recommendation' => 'Recommend status_var'), + array('justification' => 'foo', 'name' => 'Variable', 'issue' => 'issue', 'recommendation' => 'Recommend status_var'), ), array( array('justification' => '%s foo | value', 'name' => 'Format', 'issue' => 'issue', 'recommendation' => 'Recommend'), From 7654af9632d9f56a791a3019a41624aca3a16ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 11:21:38 +0200 Subject: [PATCH 07/13] Add test for errors --- test/classes/Advisor_test.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/classes/Advisor_test.php b/test/classes/Advisor_test.php index d5d9dda81f..1f28dd8357 100644 --- a/test/classes/Advisor_test.php +++ b/test/classes/Advisor_test.php @@ -50,17 +50,19 @@ class Advisor_test extends PHPUnit_Framework_TestCase * @depends testParse * @dataProvider rulesProvider */ - public function testAddRule($rule, $expected) + public function testAddRule($rule, $expected, $errors) { $advisor = new Advisor(); $parseResult = $advisor->parseRulesFile(); $this->assertEquals($parseResult['errors'], array()); $advisor->variables['value'] = 0; $advisor->addRule('fired', $rule); - if (isset($advisor->runResult['errors'])) { + if (isset($advisor->runResult['errors']) || $errors != array()) { $this->assertEquals($advisor->runResult['errors'], array()); } - $this->assertEquals($advisor->runResult['fired'], array($expected)); + if (isset($advisor->runResult['fired']) || $expected != array()) { + $this->assertEquals($advisor->runResult['fired'], array($expected)); + } } public function rulesProvider() @@ -69,22 +71,27 @@ class Advisor_test extends PHPUnit_Framework_TestCase array( array('justification' => 'foo', 'name' => 'Basic', 'issue' => 'issue', 'recommendation' => 'Recommend'), array('justification' => 'foo', 'name' => 'Basic', 'issue' => 'issue', 'recommendation' => 'Recommend'), + array(), ), array( array('justification' => 'foo', 'name' => 'Variable', 'issue' => 'issue', 'recommendation' => 'Recommend {status_var}'), array('justification' => 'foo', 'name' => 'Variable', 'issue' => 'issue', 'recommendation' => 'Recommend status_var'), + array(), ), array( array('justification' => '%s foo | value', 'name' => 'Format', 'issue' => 'issue', 'recommendation' => 'Recommend'), array('justification' => '0 foo', 'name' => 'Format', 'issue' => 'issue', 'recommendation' => 'Recommend'), + array(), ), array( array('justification' => '%s% foo | value', 'name' => 'Percent', 'issue' => 'issue', 'recommendation' => 'Recommend'), array('justification' => '0% foo', 'name' => 'Percent', 'issue' => 'issue', 'recommendation' => 'Recommend'), + array(), ), array( array('justification' => '"\'foo', 'name' => 'Quotes', 'issue' => 'issue', 'recommendation' => 'Recommend"\''), array('justification' => '"\'foo', 'name' => 'Quotes', 'issue' => 'issue', 'recommendation' => 'Recommend"\''), + array(), ), ); } From 74764f3cf1c238fed2cdb29e62fb59bbcf771c69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 11:24:22 +0200 Subject: [PATCH 08/13] Add test case for failed eval --- test/classes/Advisor_test.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/test/classes/Advisor_test.php b/test/classes/Advisor_test.php index 1f28dd8357..d2be7741a5 100644 --- a/test/classes/Advisor_test.php +++ b/test/classes/Advisor_test.php @@ -50,15 +50,15 @@ class Advisor_test extends PHPUnit_Framework_TestCase * @depends testParse * @dataProvider rulesProvider */ - public function testAddRule($rule, $expected, $errors) + public function testAddRule($rule, $expected, $error) { $advisor = new Advisor(); $parseResult = $advisor->parseRulesFile(); $this->assertEquals($parseResult['errors'], array()); $advisor->variables['value'] = 0; $advisor->addRule('fired', $rule); - if (isset($advisor->runResult['errors']) || $errors != array()) { - $this->assertEquals($advisor->runResult['errors'], array()); + if (isset($advisor->runResult['errors']) || !is_null($error)) { + $this->assertEquals($advisor->runResult['errors'], array($error)); } if (isset($advisor->runResult['fired']) || $expected != array()) { $this->assertEquals($advisor->runResult['fired'], array($expected)); @@ -71,27 +71,32 @@ class Advisor_test extends PHPUnit_Framework_TestCase array( array('justification' => 'foo', 'name' => 'Basic', 'issue' => 'issue', 'recommendation' => 'Recommend'), array('justification' => 'foo', 'name' => 'Basic', 'issue' => 'issue', 'recommendation' => 'Recommend'), - array(), + null, ), array( array('justification' => 'foo', 'name' => 'Variable', 'issue' => 'issue', 'recommendation' => 'Recommend {status_var}'), array('justification' => 'foo', 'name' => 'Variable', 'issue' => 'issue', 'recommendation' => 'Recommend status_var'), - array(), + null, ), array( array('justification' => '%s foo | value', 'name' => 'Format', 'issue' => 'issue', 'recommendation' => 'Recommend'), array('justification' => '0 foo', 'name' => 'Format', 'issue' => 'issue', 'recommendation' => 'Recommend'), - array(), + null, ), array( array('justification' => '%s% foo | value', 'name' => 'Percent', 'issue' => 'issue', 'recommendation' => 'Recommend'), array('justification' => '0% foo', 'name' => 'Percent', 'issue' => 'issue', 'recommendation' => 'Recommend'), - array(), + null, ), array( array('justification' => '"\'foo', 'name' => 'Quotes', 'issue' => 'issue', 'recommendation' => 'Recommend"\''), array('justification' => '"\'foo', 'name' => 'Quotes', 'issue' => 'issue', 'recommendation' => 'Recommend"\''), + null, + ), + array( + array('justification' => 'foo | fsafdsa', 'name' => 'Failure', 'issue' => 'issue', 'recommendation' => 'Recommend'), array(), + 'Failed formattingstring for rule \'Failure\'. PHP threw following error: Use of undefined constant fsafdsa - assumed \'fsafdsa\'', ), ); } From bbccd32c816b2bf56e3e36c8c0f86a42ca15dd37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 11:33:00 +0200 Subject: [PATCH 09/13] Improve coding style --- libraries/schema/User_Schema.class.php | 37 +++++++++++++++++++++----- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php index 2ea0a2b42a..94850c263a 100644 --- a/libraries/schema/User_Schema.class.php +++ b/libraries/schema/User_Schema.class.php @@ -45,24 +45,49 @@ class PMA_User_Schema case 'selectpage': $this->chosenPage = $_REQUEST['chpage']; if ($action_choose=="1") { - $this->deleteCoordinates($db, $cfgRelation, $this->chosenPage, $query_default_option); - $this->deletePages($db, $cfgRelation, $this->chosenPage, $query_default_option); + $this->deleteCoordinates( + $db, + $cfgRelation, + $this->chosenPage, + $query_default_option + ); + $this->deletePages( + $db, + $cfgRelation, + $this->chosenPage, + $query_default_option + ); $this->chosenPage = 0; } break; case 'createpage': - $this->pageNumber = PMA_REL_create_page($_POST['newpage'], $cfgRelation, $db, $query_default_option); + $this->pageNumber = PMA_REL_create_page( + $_POST['newpage'], + $cfgRelation, + $db, + $query_default_option + ); $this->autoLayoutForeign = isset($_POST['auto_layout_foreign']) ? "1":NULL; $this->autoLayoutInternal = isset($_POST['auto_layout_internal']) ? "1":NULL; - $this->processRelations($db, $this->pageNumber,$cfgRelation,$query_default_option); + $this->processRelations( + $db, + $this->pageNumber, + $cfgRelation, + $query_default_option + ); break; case 'edcoord': $this->chosenPage = $_POST['chpage']; $this->c_table_rows = $_POST['c_table_rows']; - $this->_editCoordinates($db, $cfgRelation,$query_default_option); + $this->_editCoordinates($db, $cfgRelation, $query_default_option); break; case 'delete_old_references': - $this->_deleteTableRows($delrow,$cfgRelation,$db,$this->chosenPage); + $this->_deleteTableRows( + $delrow, + $cfgRelation, + $db, + $this->chosenPage + ); break; case 'process_export': $this->_processExportSchema(); From b0a108473e3087fa50b121ed48e16809e9ace20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 11:36:13 +0200 Subject: [PATCH 10/13] Remove not needed param from PMA_REL_create_page --- libraries/relation.lib.php | 3 +-- libraries/schema/User_Schema.class.php | 3 +-- pmd_pdf.php | 18 +++++++----------- schema_edit.php | 23 ++++++++--------------- schema_export.php | 12 ++---------- 5 files changed, 19 insertions(+), 40 deletions(-) diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index c24c2491e7..bc86994b12 100644 --- a/libraries/relation.lib.php +++ b/libraries/relation.lib.php @@ -1068,10 +1068,9 @@ function PMA_REL_renameField($db, $table, $field, $new_name) * @param string $newpage * @param array $cfgRelation * @param string $db - * @param string $query_default_option * @return string $pdf_page_number */ -function PMA_REL_create_page($newpage, $cfgRelation, $db, $query_default_option) +function PMA_REL_create_page($newpage, $cfgRelation, $db) { if (! isset($newpage) || $newpage == '') { $newpage = __('no description'); diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php index 94850c263a..dc86c4c6f6 100644 --- a/libraries/schema/User_Schema.class.php +++ b/libraries/schema/User_Schema.class.php @@ -64,8 +64,7 @@ class PMA_User_Schema $this->pageNumber = PMA_REL_create_page( $_POST['newpage'], $cfgRelation, - $db, - $query_default_option + $db ); $this->autoLayoutForeign = isset($_POST['auto_layout_foreign']) ? "1":NULL; $this->autoLayoutInternal = isset($_POST['auto_layout_internal']) ? "1":NULL; diff --git a/pmd_pdf.php b/pmd_pdf.php index d697dd58cc..adf5fac13d 100644 --- a/pmd_pdf.php +++ b/pmd_pdf.php @@ -8,7 +8,7 @@ include_once 'pmd_common.php'; /** - * If called directly from the designer, first save the positions + * If called directly from the designer, first save the positions */ if (! isset($scale)) { $no_die_save_pos = 1; @@ -25,11 +25,7 @@ if (isset($mode)) { $scale_q = PMA_sqlAddSlashes($scale); if ('create_export' == $mode) { - /* - * @see pdf_pages.php - */ - $query_default_option = PMA_DBI_QUERY_STORE; - $pdf_page_number = PMA_REL_create_page($newpage, $cfgRelation, $db, $query_default_option); + $pdf_page_number = PMA_REL_create_page($newpage, $cfgRelation, $db); if ($pdf_page_number > 0) { $message = PMA_Message::success(__('Page has been created')); $mode = 'export'; @@ -57,7 +53,7 @@ if (isset($mode)) { ' . $pmd_table . '.`table_name` = ' . $pma_table . '.`table_name` AND ' . $pmd_table . '.`db_name`=\''. PMA_sqlAddSlashes($db) .'\' - AND pdf_page_number = ' . $pdf_page_number_q . ';', true, PMA_DBI_QUERY_STORE); + AND pdf_page_number = ' . $pdf_page_number_q . ';', true, PMA_DBI_QUERY_STORE); } } @@ -68,20 +64,20 @@ require_once './libraries/header_meta_style.inc.php';
-display(); } ?>
-'; echo '
' . __('Import/Export coordinates for PDF schema') . ''; $choices = array(); -$table_info_result = PMA_query_as_controluser('SELECT * FROM ' +$table_info_result = PMA_query_as_controluser('SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''); diff --git a/schema_edit.php b/schema_edit.php index 4ab41d4539..3662b0b161 100644 --- a/schema_edit.php +++ b/schema_edit.php @@ -20,19 +20,12 @@ require_once './libraries/db_info.inc.php'; /** * Includ settings for relation stuff - * get all variables needed for exporting relational schema + * get all variables needed for exporting relational schema * in $cfgRelation */ require_once './libraries/relation.lib.php'; $cfgRelation = PMA_getRelationsParam(); -/** - * This is to avoid "Command out of sync" errors. Before switching this to - * a value of 0 (for MYSQLI_USE_RESULT), please check the logic - * to free results wherever needed. - */ -$query_default_option = PMA_DBI_QUERY_STORE; - /** * Now in ./libraries/relation.lib.php we check for all tables * that we need, but if we don't find them we are quiet about it @@ -79,14 +72,14 @@ if ($cfgRelation['pdfwork']) { * and tables which will be exported as Relational schema * you can set the table positions on the paper via scratchboard * for table positions, put the x,y co-ordinates - * + * * @param string $do It tells what the Schema is supposed to do - * create and select a page, generate schema etc + * create and select a page, generate schema etc */ if (isset($_REQUEST['do'])) { $user_schema->setAction($_REQUEST['do']); $user_schema->processUserChoice(); - } + } /** * Show some possibility to select a page for the export of relation schema @@ -96,14 +89,14 @@ if ($cfgRelation['pdfwork']) { $user_schema->selectPage(); /** - * Create a new page where relations will be drawn + * Create a new page where relations will be drawn */ $user_schema->showCreatePageDialog($db); /** - * After selection of page or creating a page - * It will show you the list of tables + * After selection of page or creating a page + * It will show you the list of tables * A dashboard will also be shown where you can position the tables */ @@ -114,7 +107,7 @@ if ($cfgRelation['pdfwork']) { || ($_REQUEST['do']== 'selectpage' && isset($user_schema->chosenPage) && $user_schema->chosenPage != 0) || ($_REQUEST['do'] == 'createpage' && isset($user_schema->chosenPage) && $user_schema->chosenPage != 0))) { - /** + /** * show Export schema generation options */ $user_schema->displaySchemaGenerationOptions(); diff --git a/schema_export.php b/schema_export.php index 3e1067d55e..2abe91f9e6 100644 --- a/schema_export.php +++ b/schema_export.php @@ -13,7 +13,7 @@ require './libraries/StorageEngine.class.php'; /** * Include settings for relation stuff - * get all variables needed for exporting relational schema + * get all variables needed for exporting relational schema * in $cfgRelation */ require_once './libraries/relation.lib.php'; @@ -21,14 +21,6 @@ $cfgRelation = PMA_getRelationsParam(); require_once './libraries/transformations.lib.php'; require_once './libraries/Index.class.php'; - -/** - * This is to avoid "Command out of sync" errors. Before switching this to - * a value of 0 (for MYSQLI_USE_RESULT), please check the logic - * to free results wherever needed. - */ -$query_default_option = PMA_DBI_QUERY_STORE; - include_once("./libraries/schema/Export_Relation_Schema.class.php"); /** @@ -47,4 +39,4 @@ if (!file_exists('./libraries/schema/' . $path . '_Relation_Schema.class.php')) PMA_Export_Relation_Schema::dieSchema($_POST['chpage'],$export_type,__('File doesn\'t exist')); } include("./libraries/schema/".$path."_Relation_Schema.class.php"); -$obj_schema = eval("new PMA_".$path."_Relation_Schema();"); \ No newline at end of file +$obj_schema = eval("new PMA_".$path."_Relation_Schema();"); From 21e2913adde82d36cfa9ab2daaab90d3a4b185f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 11:37:23 +0200 Subject: [PATCH 11/13] Remove not needed param from PMA_REL_create_page --- libraries/relation.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index bc86994b12..44117434b9 100644 --- a/libraries/relation.lib.php +++ b/libraries/relation.lib.php @@ -1078,7 +1078,7 @@ function PMA_REL_create_page($newpage, $cfgRelation, $db) $ins_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . ' (db_name, page_descr)' . ' VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' . PMA_sqlAddSlashes($newpage) . '\')'; - PMA_query_as_controluser($ins_query, false, $query_default_option); + PMA_query_as_controluser($ins_query, false); return PMA_DBI_insert_id(isset($GLOBALS['controllink']) ? $GLOBALS['controllink'] : ''); } ?> From b3939c021af17416deae247d8e3365c8975a9f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 15 Aug 2011 11:41:49 +0200 Subject: [PATCH 12/13] Remove not needed global $query_default_option --- libraries/schema/User_Schema.class.php | 47 ++++++++++++-------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php index dc86c4c6f6..aa17c4717b 100644 --- a/libraries/schema/User_Schema.class.php +++ b/libraries/schema/User_Schema.class.php @@ -38,7 +38,7 @@ class PMA_User_Schema public function processUserChoice() { - global $action_choose,$db,$cfgRelation,$cfg,$query_default_option; + global $action_choose,$db,$cfgRelation,$cfg; if (isset($this->action)) { switch ($this->action) { @@ -48,14 +48,12 @@ class PMA_User_Schema $this->deleteCoordinates( $db, $cfgRelation, - $this->chosenPage, - $query_default_option + $this->chosenPage ); $this->deletePages( $db, $cfgRelation, - $this->chosenPage, - $query_default_option + $this->chosenPage ); $this->chosenPage = 0; } @@ -71,14 +69,13 @@ class PMA_User_Schema $this->processRelations( $db, $this->pageNumber, - $cfgRelation, - $query_default_option + $cfgRelation ); break; case 'edcoord': $this->chosenPage = $_POST['chpage']; $this->c_table_rows = $_POST['c_table_rows']; - $this->_editCoordinates($db, $cfgRelation, $query_default_option); + $this->_editCoordinates($db, $cfgRelation); break; case 'delete_old_references': $this->_deleteTableRows( @@ -156,10 +153,10 @@ class PMA_User_Schema */ public function selectPage() { - global $db,$table,$query_default_option,$cfgRelation; + global $db,$table,$cfgRelation; $page_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''; - $page_rs = PMA_query_as_controluser($page_query, false, $query_default_option); + $page_rs = PMA_query_as_controluser($page_query, false, PMA_DBI_QUERY_STORE); if ($page_rs && PMA_DBI_num_rows($page_rs) > 0) { ?> @@ -210,7 +207,7 @@ class PMA_User_Schema */ public function showTableDashBoard() { - global $db,$cfgRelation,$table,$cfg,$with_field_names,$query_default_option; + global $db,$cfgRelation,$table,$cfg,$with_field_names; /* * We will need an array of all tables in this db */ @@ -233,7 +230,7 @@ class PMA_User_Schema $page_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\''; - $page_rs = PMA_query_as_controluser($page_query, false, $query_default_option); + $page_rs = PMA_query_as_controluser($page_query, false); $array_sh_page = array(); while ($temp_sh_page = @PMA_DBI_fetch_assoc($page_rs)) { $array_sh_page[] = $temp_sh_page; @@ -567,7 +564,7 @@ class PMA_User_Schema . ' AND table_name = \'' . PMA_sqlAddSlashes($current_row) . '\'' . "\n" . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($chpage) . '\''; echo $del_query; - PMA_query_as_controluser($del_query, false, $query_default_option); + PMA_query_as_controluser($del_query, false); } } @@ -608,12 +605,12 @@ class PMA_User_Schema * @return void * @access private */ - public function deleteCoordinates($db, $cfgRelation, $choosePage, $query_default_option) + public function deleteCoordinates($db, $cfgRelation, $choosePage) { $query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($choosePage) . '\''; - PMA_query_as_controluser($query, false, $query_default_option); + PMA_query_as_controluser($query, false); } /** @@ -625,12 +622,12 @@ class PMA_User_Schema * @return void * @access private */ - public function deletePages($db, $cfgRelation, $choosePage, $query_default_option) + public function deletePages($db, $cfgRelation, $choosePage) { $query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . ' AND page_nr = \'' . PMA_sqlAddSlashes($choosePage) . '\''; - PMA_query_as_controluser($query, false, $query_default_option); + PMA_query_as_controluser($query, false); } /** @@ -642,7 +639,7 @@ class PMA_User_Schema * @return void * @access private */ - public function processRelations($db, $pageNumber, $cfgRelation, $query_default_option) + public function processRelations($db, $pageNumber, $cfgRelation) { /* * A u t o m a t i c l a y o u t @@ -689,7 +686,7 @@ class PMA_User_Schema . ' WHERE master_db = \'' . $db . '\'' . ' GROUP BY master_table' . ' ORDER BY ' . PMA_backquote('COUNT(master_table)') . ' DESC '; - $master_tables_rs = PMA_query_as_controluser($master_tables, false, $query_default_option); + $master_tables_rs = PMA_query_as_controluser($master_tables, false, PMA_DBI_QUERY_STORE); if ($master_tables_rs && PMA_DBI_num_rows($master_tables_rs) > 0) { /* first put all the master tables at beginning * of the list, so they are near the center of @@ -727,7 +724,7 @@ class PMA_User_Schema } if (isset($this->autoLayoutInternal) || isset($this->autoLayoutForeign)) { - $this->addRelationCoordinates($all_tables,$pageNumber,$db, $cfgRelation,$query_default_option); + $this->addRelationCoordinates($all_tables,$pageNumber,$db, $cfgRelation); } $this->chosenPage = $pageNumber; @@ -743,7 +740,7 @@ class PMA_User_Schema * @return void * @access private */ - public function addRelationCoordinates($all_tables,$pageNumber,$db, $cfgRelation,$query_default_option) + public function addRelationCoordinates($all_tables,$pageNumber,$db, $cfgRelation) { /* * Now generate the coordinates for the schema @@ -761,7 +758,7 @@ class PMA_User_Schema $insert_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' ' . '(db_name, table_name, pdf_page_number, x, y) ' . 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' . PMA_sqlAddSlashes($current_table) . '\',' . $pageNumber . ',' . $pos_x . ',' . $pos_y . ')'; - PMA_query_as_controluser($insert_query, false, $query_default_option); + PMA_query_as_controluser($insert_query, false); /* * compute for the next table @@ -799,7 +796,7 @@ class PMA_User_Schema * @return void * @access private */ - private function _editCoordinates($db, $cfgRelation,$query_default_option) + private function _editCoordinates($db, $cfgRelation) { for ($i = 0; $i < $this->c_table_rows; $i++) { $arrvalue = 'c_table_' . $i; @@ -816,7 +813,7 @@ class PMA_User_Schema . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\'' . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\''; - $test_rs = PMA_query_as_controluser($test_query, false, $query_default_option); + $test_rs = PMA_query_as_controluser($test_query, false, PMA_DBI_QUERY_STORE); //echo $test_query; if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) { if (isset($arrvalue['delete']) && $arrvalue['delete'] == 'y') { @@ -837,7 +834,7 @@ class PMA_User_Schema . 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\', \'' . PMA_sqlAddSlashes($this->chosenPage) . '\',' . $arrvalue['x'] . ',' . $arrvalue['y'] . ')'; } //echo $ch_query; - PMA_query_as_controluser($ch_query, false, $query_default_option); + PMA_query_as_controluser($ch_query, false); } // end if } // end for } From e19d93a70c52fd490f0d10da6ac9adc20fbfbc65 Mon Sep 17 00:00:00 2001 From: Piotr Przybylski Date: Mon, 15 Aug 2011 11:58:54 +0200 Subject: [PATCH 13/13] Remove unneeded variables from config.default.php --- libraries/config.default.php | 308 ++--------------------------------- 1 file changed, 15 insertions(+), 293 deletions(-) diff --git a/libraries/config.default.php b/libraries/config.default.php index d8367e5839..c40e784f83 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -2753,325 +2753,49 @@ $cfg['DBG']['sql'] = false; * Column types; * VARCHAR, TINYINT, TEXT and DATE are listed first, based on estimated popularity * + * This variable is filled in data_*.inc.php + * * @global array $cfg['ColumnTypes'] */ -$cfg['ColumnTypes'] = array( - // most used - 'INT', - 'VARCHAR', - 'TEXT', - 'DATE', - - // numeric - 'NUMERIC' => array( - 'TINYINT', - 'SMALLINT', - 'MEDIUMINT', - 'INT', - 'BIGINT', - '-', - 'DECIMAL', - 'FLOAT', - 'DOUBLE', - 'REAL', - '-', - 'BIT', - 'BOOLEAN', - 'SERIAL', - ), - - - // Date/Time - 'DATE and TIME' => array( - 'DATE', - 'DATETIME', - 'TIMESTAMP', - 'TIME', - 'YEAR', - ), - - // Text - 'STRING' => array( - 'CHAR', - 'VARCHAR', - '-', - 'TINYTEXT', - 'TEXT', - 'MEDIUMTEXT', - 'LONGTEXT', - '-', - 'BINARY', - 'VARBINARY', - '-', - 'TINYBLOB', - 'MEDIUMBLOB', - 'BLOB', - 'LONGBLOB', - '-', - 'ENUM', - 'SET', - ), - - 'SPATIAL' => array( - 'GEOMETRY', - 'POINT', - 'LINESTRING', - 'POLYGON', - 'MULTIPOINT', - 'MULTILINESTRING', - 'MULTIPOLYGON', - 'GEOMETRYCOLLECTION', - ), -); +$cfg['ColumnTypes'] = array(); /** * Attributes * + * This variable is filled in data_*.inc.php + * * @global array $cfg['AttributeTypes'] */ -$cfg['AttributeTypes'] = array( - '', - 'BINARY', - 'UNSIGNED', - 'UNSIGNED ZEROFILL', - 'on update CURRENT_TIMESTAMP', -); +$cfg['AttributeTypes'] = array(); if ($cfg['ShowFunctionFields']) { /** * Available functions * + * This variable is filled in data_*.inc.php + * * @global array $cfg['Functions'] */ - $cfg['Functions'] = array( - 'ABS', - 'ACOS', - 'ASCII', - 'ASIN', - 'ATAN', - 'BIN', - 'BIT_COUNT', - 'BIT_LENGTH', - 'CEILING', - 'CHAR', - 'CHAR_LENGTH', - 'COMPRESS', - 'COS', - 'COT', - 'CRC32', - 'CURDATE', - 'CURRENT_USER', - 'CURTIME', - 'DATE', - 'DAYNAME', - 'DEGREES', - 'DES_DECRYPT', - 'DES_ENCRYPT', - 'ENCRYPT', - 'EXP', - 'FLOOR', - 'FROM_DAYS', - 'FROM_UNIXTIME', - 'HEX', - 'INET_ATON', - 'INET_NTOA', - 'LENGTH', - 'LN', - 'LOG', - 'LOG10', - 'LOG2', - 'LOWER', - 'MD5', - 'NOW', - 'OCT', - 'OLD_PASSWORD', - 'ORD', - 'PASSWORD', - 'RADIANS', - 'RAND', - 'REVERSE', - 'ROUND', - 'SEC_TO_TIME', - 'SHA1', - 'SOUNDEX', - 'SPACE', - 'SQRT', - 'STDDEV_POP', - 'STDDEV_SAMP', - 'TAN', - 'TIMESTAMP', - 'TIME_TO_SEC', - 'UNCOMPRESS', - 'UNHEX', - 'UNIX_TIMESTAMP', - 'UPPER', - 'USER', - 'UTC_DATE', - 'UTC_TIME', - 'UTC_TIMESTAMP', - 'UUID', - 'VAR_POP', - 'VAR_SAMP', - 'YEAR', - ); + $cfg['Functions'] = array(); /** * Which column types will be mapped to which Group? * + * This variable is filled in data_*.inc.php + * * @global array $cfg['RestrictColumnTypes'] */ - $cfg['RestrictColumnTypes'] = array( - 'TINYINT' => 'FUNC_NUMBER', - 'SMALLINT' => 'FUNC_NUMBER', - 'MEDIUMINT' => 'FUNC_NUMBER', - 'INT' => 'FUNC_NUMBER', - 'BIGINT' => 'FUNC_NUMBER', - 'DECIMAL' => 'FUNC_NUMBER', - 'FLOAT' => 'FUNC_NUMBER', - 'DOUBLE' => 'FUNC_NUMBER', - 'REAL' => 'FUNC_NUMBER', - 'BIT' => 'FUNC_NUMBER', - 'BOOLEAN' => 'FUNC_NUMBER', - 'SERIAL' => 'FUNC_NUMBER', - - 'DATE' => 'FUNC_DATE', - 'DATETIME' => 'FUNC_DATE', - 'TIMESTAMP' => 'FUNC_DATE', - 'TIME' => 'FUNC_DATE', - 'YEAR' => 'FUNC_DATE', - - 'CHAR' => 'FUNC_CHAR', - 'VARCHAR' => 'FUNC_CHAR', - 'TINYTEXT' => 'FUNC_CHAR', - 'TEXT' => 'FUNC_CHAR', - 'MEDIUMTEXT' => 'FUNC_CHAR', - 'LONGTEXT' => 'FUNC_CHAR', - 'BINARY' => 'FUNC_CHAR', - 'VARBINARY' => 'FUNC_CHAR', - 'TINYBLOB' => 'FUNC_CHAR', - 'MEDIUMBLOB' => 'FUNC_CHAR', - 'BLOB' => 'FUNC_CHAR', - 'LONGBLOB' => 'FUNC_CHAR', - 'ENUM' => '', - 'SET' => '', - - 'GEOMETRY' => 'FUNC_SPATIAL', - 'POINT' => 'FUNC_SPATIAL', - 'LINESTRING' => 'FUNC_SPATIAL', - 'POLYGON' => 'FUNC_SPATIAL', - 'MULTIPOINT' => 'FUNC_SPATIAL', - 'MULTILINESTRING' => 'FUNC_SPATIAL', - 'MULTIPOLYGON' => 'FUNC_SPATIAL', - 'GEOMETRYCOLLECTION' => 'FUNC_SPATIAL', - - ); + $cfg['RestrictColumnTypes'] = array(); /** * Map above defined groups to any function * + * This variable is filled in data_*.inc.php + * * @global array $cfg['RestrictFunctions'] */ - $cfg['RestrictFunctions'] = array( - 'FUNC_CHAR' => array( - 'BIN', - 'CHAR', - 'CURRENT_USER', - 'COMPRESS', - 'DAYNAME', - 'DES_DECRYPT', - 'DES_ENCRYPT', - 'ENCRYPT', - 'HEX', - 'INET_NTOA', - 'LOWER', - 'MD5', - 'OLD_PASSWORD', - 'PASSWORD', - 'REVERSE', - 'SHA1', - 'SOUNDEX', - 'SPACE', - 'UNCOMPRESS', - 'UNHEX', - 'UPPER', - 'USER', - 'UUID', - ), - - 'FUNC_DATE' => array( - 'CURDATE', - 'CURTIME', - 'DATE', - 'FROM_DAYS', - 'FROM_UNIXTIME', - 'NOW', - 'SEC_TO_TIME', - 'TIMESTAMP', - 'UTC_DATE', - 'UTC_TIME', - 'UTC_TIMESTAMP', - 'YEAR', - ), - - 'FUNC_NUMBER' => array( - 'ABS', - 'ACOS', - 'ASCII', - 'ASIN', - 'ATAN', - 'BIT_LENGTH', - 'BIT_COUNT', - 'CEILING', - 'CHAR_LENGTH', - 'COS', - 'COT', - 'CRC32', - 'DEGREES', - 'EXP', - 'FLOOR', - 'INET_ATON', - 'LENGTH', - 'LN', - 'LOG', - 'LOG2', - 'LOG10', - 'OCT', - 'ORD', - 'RADIANS', - 'RAND', - 'ROUND', - 'SQRT', - 'STDDEV_POP', - 'STDDEV_SAMP', - 'TAN', - 'TIME_TO_SEC', - 'UNIX_TIMESTAMP', - 'VAR_POP', - 'VAR_SAMP', - ), - - 'FUNC_SPATIAL' => array( - 'GeomFromText', - 'GeomFromWKB', - - 'GeomCollFromText', - 'LineFromText', - 'MLineFromText', - 'PointFromText', - 'MPointFromText', - 'PolyFromText', - 'MPolyFromText', - - 'GeomCollFromWKB', - 'LineFromWKB', - 'MLineFromWKB', - 'PointFromWKB', - 'MPointFromWKB', - 'PolyFromWKB', - 'MPolyFromWKB', - ), - ); + $cfg['RestrictFunctions'] = array(); /** * Default functions for above defined groups @@ -3085,8 +2809,6 @@ if ($cfg['ShowFunctionFields']) { 'first_timestamp' => 'NOW', 'pk_char36' => 'UUID', ); - - } // end if /**