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(); } 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 /** diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index c24c2491e7..44117434b9 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'); @@ -1079,7 +1078,7 @@ function PMA_REL_create_page($newpage, $cfgRelation, $db, $query_default_option) $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'] : ''); } ?> diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php index 2ea0a2b42a..aa17c4717b 100644 --- a/libraries/schema/User_Schema.class.php +++ b/libraries/schema/User_Schema.class.php @@ -38,31 +38,52 @@ 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) { 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 + ); + $this->deletePages( + $db, + $cfgRelation, + $this->chosenPage + ); $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 + ); $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 + ); 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($delrow,$cfgRelation,$db,$this->chosenPage); + $this->_deleteTableRows( + $delrow, + $cfgRelation, + $db, + $this->chosenPage + ); break; case 'process_export': $this->_processExportSchema(); @@ -132,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) { ?>
@@ -186,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 */ @@ -209,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; @@ -543,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); } } @@ -584,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); } /** @@ -601,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); } /** @@ -618,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 @@ -665,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 @@ -703,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; @@ -719,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 @@ -737,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 @@ -775,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; @@ -792,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') { @@ -813,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 } 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();"); diff --git a/test/classes/Advisor_test.php b/test/classes/Advisor_test.php index ac43516eb1..d2be7741a5 100644 --- a/test/classes/Advisor_test.php +++ b/test/classes/Advisor_test.php @@ -10,9 +10,18 @@ * 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 { + public function setup() + { + $_SESSION[' PMA_token '] = 'token'; + $GLOBALS['lang'] = 'en'; + } + /** * @dataProvider escapeStrings */ @@ -33,8 +42,63 @@ class Advisor_test extends PHPUnit_Framework_TestCase public function testParse() { $advisor = new Advisor(); - $parseResult = $this->parseRulesFile(); + $parseResult = $advisor->parseRulesFile(); $this->assertEquals($parseResult['errors'], array()); } + + /** + * @depends testParse + * @dataProvider rulesProvider + */ + 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']) || !is_null($error)) { + $this->assertEquals($advisor->runResult['errors'], array($error)); + } + if (isset($advisor->runResult['fired']) || $expected != array()) { + $this->assertEquals($advisor->runResult['fired'], array($expected)); + } + } + + public function rulesProvider() + { + return array( + array( + array('justification' => 'foo', 'name' => 'Basic', 'issue' => 'issue', 'recommendation' => 'Recommend'), + array('justification' => 'foo', 'name' => 'Basic', 'issue' => 'issue', 'recommendation' => 'Recommend'), + null, + ), + array( + array('justification' => 'foo', 'name' => 'Variable', 'issue' => 'issue', 'recommendation' => 'Recommend {status_var}'), + array('justification' => 'foo', 'name' => 'Variable', 'issue' => 'issue', 'recommendation' => 'Recommend status_var'), + null, + ), + array( + array('justification' => '%s foo | value', 'name' => 'Format', 'issue' => 'issue', 'recommendation' => 'Recommend'), + array('justification' => '0 foo', 'name' => 'Format', 'issue' => 'issue', 'recommendation' => 'Recommend'), + null, + ), + array( + array('justification' => '%s% foo | value', 'name' => 'Percent', 'issue' => 'issue', 'recommendation' => 'Recommend'), + array('justification' => '0% foo', 'name' => 'Percent', 'issue' => 'issue', 'recommendation' => 'Recommend'), + 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\'', + ), + ); + } } ?>