From 4e534c977f7bf51aa2c5c6879d2112c79d1bedda Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Fri, 9 Sep 2016 14:12:50 +0530 Subject: [PATCH 01/35] Fix Export and Copy of Tables with Generated/Virtual columns We include only the non-generated columns insert using INSERT INTO .. SELECT .. FROM .. while copying data. In Export too, we export the data of only the non-generated columns Fix #12221 Fix #12518 Signed-off-by: Deven Bansod --- libraries/Table.php | 43 ++++++++++++++++++++++++++++++++++++---- libraries/export.lib.php | 14 +++++++++++-- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/libraries/Table.php b/libraries/Table.php index ccc9df873109..f8b0264ad8da 100644 --- a/libraries/Table.php +++ b/libraries/Table.php @@ -1017,10 +1017,17 @@ static public function moveCopy($source_db, $source_table, $target_db, $GLOBALS['dbi']->query($sql_set_mode); $GLOBALS['sql_query'] .= "\n\n" . $sql_set_mode . ';'; - $sql_insert_data = 'INSERT INTO ' . $target - . ' SELECT * FROM ' . $source; - $GLOBALS['dbi']->query($sql_insert_data); - $GLOBALS['sql_query'] .= "\n\n" . $sql_insert_data . ';'; + $_old_table = new Table($source_table, $source_db); + $nonGeneratedCols = $_old_table->getNonGeneratedColumns(true); + if (count($nonGeneratedCols) > 0) { + $sql_insert_data = 'INSERT INTO ' . $target . '(' + . implode(', ', $nonGeneratedCols) + . ') SELECT ' . implode(', ', $nonGeneratedCols) + . ' FROM ' . $source; + + $GLOBALS['dbi']->query($sql_insert_data); + $GLOBALS['sql_query'] .= "\n\n" . $sql_insert_data . ';'; + } } PMA_getRelationsParam(); @@ -1484,6 +1491,34 @@ public function getColumnsMeta() } } + /** + * Get non-generated columns in table + * + * @param bool $backquoted whether to quote name with backticks `` + * + * @return array + */ + public function getNonGeneratedColumns($backquoted = true) + { + $columns_meta_query = sprintf( + 'SHOW COLUMNS FROM %s.%s', + Util::backquote($this->_db_name), + Util::backquote($this->_name) + ); + $ret = array(); + + $columns_meta_query_result = $this->_dbi->tryQuery($columns_meta_query); + if ($columns_meta_query_result !== false) { + foreach ($columns_meta_query_result as $column) { + if (strpos($column['Extra'], 'GENERATED') === false) { + array_push($ret, Util::backquote($column['Field'])); + } + } + } + + return $ret; + } + /** * Return UI preferences for this table from phpMyAdmin database. * diff --git a/libraries/export.lib.php b/libraries/export.lib.php index 20567d969862..e432d1ceb830 100644 --- a/libraries/export.lib.php +++ b/libraries/export.lib.php @@ -682,8 +682,13 @@ function PMA_exportDatabase( && in_array($table, $table_data) && ! ($is_view) ) { - $local_query = 'SELECT * FROM ' . PMA\libraries\Util::backquote($db) + $tableObj = new PMA\libraries\Table($table, $db); + $nonGeneratedCols = $tableObj->getNonGeneratedColumns(true); + + $local_query = 'SELECT ' . implode(', ', $nonGeneratedCols) + . ' FROM ' . PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote($table); + if (! $export_plugin->exportData( $db, $table, $crlf, $err_url, $local_query, $aliases )) { @@ -862,7 +867,12 @@ function PMA_exportTable( $local_query = $sql_query . $add_query; $GLOBALS['dbi']->selectDb($db); } else { - $local_query = 'SELECT * FROM ' . PMA\libraries\Util::backquote($db) + // Data is exported only for Non-generated columns + $tableObj = new PMA\libraries\Table($table, $db); + $nonGeneratedCols = $tableObj->getNonGeneratedColumns(true); + + $local_query = 'SELECT ' . implode(', ', $nonGeneratedCols) + . ' FROM ' . PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote($table) . $add_query; } if (! $export_plugin->exportData( From 429c679f776e780db22481e94d31e07d81977dbd Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Fri, 9 Sep 2016 15:56:22 +0530 Subject: [PATCH 02/35] Fix tests, added testcase for Generated columns in moveCopy Signed-off-by: Deven Bansod --- libraries/Table.php | 15 ++++++++------- test/classes/TableTest.php | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/libraries/Table.php b/libraries/Table.php index f8b0264ad8da..ce49bcb61025 100644 --- a/libraries/Table.php +++ b/libraries/Table.php @@ -1500,15 +1500,16 @@ public function getColumnsMeta() */ public function getNonGeneratedColumns($backquoted = true) { - $columns_meta_query = sprintf( - 'SHOW COLUMNS FROM %s.%s', - Util::backquote($this->_db_name), - Util::backquote($this->_name) - ); + $columns_meta_query = 'SHOW COLUMNS FROM ' . $this->getFullName(true); $ret = array(); - $columns_meta_query_result = $this->_dbi->tryQuery($columns_meta_query); - if ($columns_meta_query_result !== false) { + $columns_meta_query_result = $this->_dbi->fetchResult( + $columns_meta_query + ); + + if ($columns_meta_query_result + && $columns_meta_query_result !== false + ) { foreach ($columns_meta_query_result as $column) { if (strpos($column['Extra'], 'GENERATED') === false) { array_push($ret, Util::backquote($column['Field'])); diff --git a/test/classes/TableTest.php b/test/classes/TableTest.php index 55f1c9b9d646..0fe7073670cd 100644 --- a/test/classes/TableTest.php +++ b/test/classes/TableTest.php @@ -180,6 +180,31 @@ protected function setUp() 'ALL' ) ), + array( + 'SHOW COLUMNS FROM `PMA`.`PMA_BookMark`', + null, + null, + null, + 0, + array( + array( + 'Field'=>'COLUMN_NAME1', + 'Type'=> 'INT(10)', + 'Null'=> 'NO', + 'Key'=> '', + 'Default'=> NULL, + 'Extra'=>'' + ), + array( + 'Field'=>'COLUMN_NAME2', + 'Type'=> 'INT(10)', + 'Null'=> 'YES', + 'Key'=> '', + 'Default'=> NULL, + 'Extra'=>'STORED GENERATED' + ) + ) + ), ); $dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface') @@ -1047,7 +1072,8 @@ public function testMoveCopy() $expect, $return ); - $sql_query = "INSERT INTO `PMA_new`.`PMA_BookMark_new` SELECT * FROM " + $sql_query = "INSERT INTO `PMA_new`.`PMA_BookMark_new`(`COLUMN_NAME1`)" + . " SELECT `COLUMN_NAME1` FROM " . "`PMA`.`PMA_BookMark`"; $this->assertContains( $sql_query, @@ -1070,8 +1096,9 @@ public function testMoveCopy() $expect, $return ); - $sql_query = "INSERT INTO `PMA_new`.`PMA_BookMark_new` SELECT * FROM " - . "`PMA`.`PMA_BookMark`;"; + $sql_query = "INSERT INTO `PMA_new`.`PMA_BookMark_new`(`COLUMN_NAME1`)" + . " SELECT `COLUMN_NAME1` FROM " + . "`PMA`.`PMA_BookMark`"; $this->assertContains( $sql_query, $GLOBALS['sql_query'] From 5145c8c3238eaca1d0a6b80adc9f7c8e07d6bfef Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Tue, 13 Sep 2016 13:09:34 +0530 Subject: [PATCH 03/35] Fix #12320 : Copying a user does not copy usergroup Signed-off-by: Deven Bansod --- libraries/server_privileges.lib.php | 44 +++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/libraries/server_privileges.lib.php b/libraries/server_privileges.lib.php index 059595e619fd..932d7a3d136b 100644 --- a/libraries/server_privileges.lib.php +++ b/libraries/server_privileges.lib.php @@ -2951,6 +2951,33 @@ function PMA_getUserGroupCount() return $user_group_count; } +/** + * Returns name of user group that user is part of + * + * @param string $username User name + * + * @return mixed usergroup if found or null if not found + */ +function PMA_getUserGroupForUser($username) +{ + $cfgRelation = PMA_getRelationsParam(); + $user_table = Util::backquote($cfgRelation['db']) + . '.' . Util::backquote($cfgRelation['users']); + $sql_query = 'SELECT `usergroup` FROM ' . $user_table + . ' WHERE `username` = \'' . $username . '\'' + . ' LIMIT 1'; + + $usergroup = $GLOBALS['dbi']->fetchValue( + $sql_query, 0, 0, $GLOBALS['controllink'] + ); + + if ($usergroup === false) { + return null; + } + + return $usergroup; +} + /** * This function return the extra data array for the ajax behavior * @@ -3129,8 +3156,15 @@ function PMA_getChangeLoginInformationHtmlForm($username, $hostname) . '' . "\n" . '' . "\n" - . '
' . "\n" + . 'value="' . htmlspecialchars($hostname) . '" />' . "\n"; + + $usergroup = PMA_getUserGroupForUser($username); + if ($usergroup !== null) { + $html_output .= '' . "\n"; + } + + $html_output .= '
' . "\n" . '' . "\n" . __('Change login information / Copy user account') . '' . "\n" @@ -4292,6 +4326,12 @@ function PMA_addUser( ); } + // Copy the user group while copying a user + $old_usergroup = + $_REQUEST['old_usergroup'] ? $_REQUEST['old_usergroup'] : null; + PMA_setUserGroup($_REQUEST['username'], $old_usergroup); + + if (isset($create_user_real)) { $queries[] = $create_user_real; } From 37ff86315b448cfa70814a6d4fa7f070491e0acc Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Tue, 13 Sep 2016 16:31:59 +0530 Subject: [PATCH 04/35] Fix usage of backquote parameter in getNonGenerated func Signed-off-by: Deven Bansod --- libraries/Table.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/Table.php b/libraries/Table.php index ce49bcb61025..d3f8032c60a0 100644 --- a/libraries/Table.php +++ b/libraries/Table.php @@ -1511,8 +1511,13 @@ public function getNonGeneratedColumns($backquoted = true) && $columns_meta_query_result !== false ) { foreach ($columns_meta_query_result as $column) { + $value = $column['Field']; + if ($backquoted === true) { + $value = Util::backquote($value); + } + if (strpos($column['Extra'], 'GENERATED') === false) { - array_push($ret, Util::backquote($column['Field'])); + array_push($ret, $value); } } } From 093620495bb5d2ce4a5571b85905ec91b78dd793 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Tue, 13 Sep 2016 22:19:01 +0530 Subject: [PATCH 05/35] Added tests for Usergroup as hidden field in Copy User form Signed-off-by: Deven Bansod --- test/libraries/PMA_server_privileges_test.php | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/test/libraries/PMA_server_privileges_test.php b/test/libraries/PMA_server_privileges_test.php index 62c9030cd105..abf318bf0171 100644 --- a/test/libraries/PMA_server_privileges_test.php +++ b/test/libraries/PMA_server_privileges_test.php @@ -1638,6 +1638,7 @@ public function testPMAGetChangeLoginInformationHtmlForm() { $username = "pma_username"; $hostname = "pma_hostname"; + $GLOBALS['cfgRelation']['menuswork'] = true; $dbi_old = $GLOBALS['dbi']; $dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface') @@ -1650,6 +1651,11 @@ public function testPMAGetChangeLoginInformationHtmlForm() $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValue($fields_info)); + $expected_userGroup = "pma_usergroup"; + + $dbi->expects($this->any())->method('fetchValue') + ->will($this->returnValue($expected_userGroup)); + $GLOBALS['dbi'] = $dbi; //PMA_getChangeLoginInformationHtmlForm @@ -1677,6 +1683,12 @@ public function testPMAGetChangeLoginInformationHtmlForm() $html ); + $this->assertContains( + '', + $html + ); + //Create a new user with the same privileges $this->assertContains( "Create a new user account with the same privileges", @@ -1686,6 +1698,38 @@ public function testPMAGetChangeLoginInformationHtmlForm() $GLOBALS['dbi'] = $dbi_old; } + /** + * Test for PMA_getUserGroupForUser + * + * @return void + */ + public function testPMAGetUserGroupForUser() + { + $username = "pma_username"; + $hostname = "pma_hostname"; + $GLOBALS['cfgRelation']['menuswork'] = true; + + $dbi_old = $GLOBALS['dbi']; + $dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + $expected_userGroup = "pma_usergroup"; + + $dbi->expects($this->any())->method('fetchValue') + ->will($this->returnValue($expected_userGroup)); + + $GLOBALS['dbi'] = $dbi; + + $returned_userGroup = PMA_getUserGroupForUser($username); + + $this->assertEquals( + $expected_userGroup, + $returned_userGroup + ); + + $GLOBALS['dbi'] = $dbi_old; + } + /** * Test for PMA_getLinkToDbAndTable * From f8ea67f2bc59d46290b85b2e578c649655f000e7 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Fri, 16 Sep 2016 13:51:34 +0530 Subject: [PATCH 06/35] Fix #12530: Show enabled links for Edit and Execute after proper priv checks Signed-off-by: Deven Bansod --- ChangeLog | 1 + js/messages.php | 2 ++ js/rte.js | 6 +++++ libraries/DatabaseInterface.php | 5 ++-- libraries/rte/rte_export.lib.php | 26 +++++++++++++----- libraries/rte/rte_list.lib.php | 42 +++++++++++++++++++++++------- libraries/rte/rte_routines.lib.php | 41 ++++++++++++++++++++--------- libraries/rte/rte_words.lib.php | 6 +++++ 8 files changed, 97 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 703d330f71d3..beea941cc0c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,6 +30,7 @@ phpMyAdmin - ChangeLog - issue #12473 Code can throw unhandled exception - issue #12550 Do not try to keep alive session even after expiry - issue #12512 Fixed rendering BBCode links in setup +- issue #12530 "Edit routine" crashes when the current user is not the definer, even if privileges are adequate 4.6.4 (2016-08-16) - issue [security] Weaknesses with cookie encryption, see PMASA-2016-29 diff --git a/js/messages.php b/js/messages.php index 9b8ecf2b3361..c79629dd1cb6 100644 --- a/js/messages.php +++ b/js/messages.php @@ -385,6 +385,8 @@ function () { $js_messages['MissingReturn'] = __('The definition of a stored function must contain a RETURN statement!'); $js_messages['strExport'] = __('Export'); +$js_messages['NoExportable'] + = __('No routine is exportable. Required privileges may be lacking.'); /* For ENUM/SET editor*/ $js_messages['enum_editor'] = __('ENUM/SET editor'); diff --git a/js/rte.js b/js/rte.js index ca2f6d4d6c5a..9a189aeae39a 100644 --- a/js/rte.js +++ b/js/rte.js @@ -128,6 +128,11 @@ RTE.COMMON = { var count = export_anchors.length; var returnCount = 0; + // No routine is exportable (due to privilege issues) + if (count === 0) { + PMA_ajaxShowMessage(PMA_messages.NoExportable); + } + export_anchors.each(function () { $.get($(this).attr('href'), {'ajax_request': true}, function (data) { returnCount++; @@ -149,6 +154,7 @@ RTE.COMMON = { } else { $.get($this.attr('href'), {'ajax_request': true}, showExport); } + PMA_ajaxRemoveMessage($msg); function showExport(data) { if (data.success === true) { diff --git a/libraries/DatabaseInterface.php b/libraries/DatabaseInterface.php index db86343fb3dc..72fd3e42c7db 100644 --- a/libraries/DatabaseInterface.php +++ b/libraries/DatabaseInterface.php @@ -1824,10 +1824,11 @@ public function getProceduresOrFunctions($db, $which, $link = null) * @param string $db db name * @param string $which PROCEDURE | FUNCTION | EVENT | VIEW * @param string $name the procedure|function|event|view name + * @param object $link MySQL link * * @return string the definition */ - public function getDefinition($db, $which, $name) + public function getDefinition($db, $which, $name, $link = null) { $returned_field = array( 'PROCEDURE' => 'Create Procedure', @@ -1838,7 +1839,7 @@ public function getDefinition($db, $which, $name) $query = 'SHOW CREATE ' . $which . ' ' . Util::backquote($db) . '.' . Util::backquote($name); - return($this->fetchValue($query, 0, $returned_field[$which])); + return($this->fetchValue($query, 0, $returned_field[$which], $link)); } /** diff --git a/libraries/rte/rte_export.lib.php b/libraries/rte/rte_export.lib.php index 55f9c2da57eb..19fa6dd0fb15 100644 --- a/libraries/rte/rte_export.lib.php +++ b/libraries/rte/rte_export.lib.php @@ -44,15 +44,17 @@ function PMA_RTE_handleExport($export_data) } else { $_db = htmlspecialchars(PMA\libraries\Util::backquote($db)); $message = __('Error in processing request:') . ' ' - . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db); - $response = Message::error($message); + . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db) + . ' OR ' . PMA_RTE_getWord('no_view'); + $message = Message::error($message); + if ($GLOBALS['is_ajax_request'] == true) { $response = PMA\libraries\Response::getInstance(); $response->setRequestStatus(false); $response->addJSON('message', $message); exit; } else { - $response->display(); + $message->display(); } } } // end PMA_RTE_handleExport() @@ -70,6 +72,9 @@ function PMA_EVN_handleExport() if (! empty($_GET['export_item']) && ! empty($_GET['item_name'])) { $item_name = $_GET['item_name']; $export_data = $GLOBALS['dbi']->getDefinition($db, 'EVENT', $item_name); + if (! $export_data) { + $export_data = false; + } PMA_RTE_handleExport($export_data); } } // end PMA_EVN_handleExport() @@ -89,13 +94,20 @@ function PMA_RTN_handleExport() && ! empty($_GET['item_type']) ) { if ($_GET['item_type'] == 'FUNCTION' || $_GET['item_type'] == 'PROCEDURE') { - $export_data = "DELIMITER $$\n" - . $GLOBALS['dbi']->getDefinition( + $rtn_definition + = $GLOBALS['dbi']->getDefinition( $db, $_GET['item_type'], $_GET['item_name'] - ) - . "$$\nDELIMITER ;\n"; + ); + if (! $rtn_definition) { + $export_data = false; + } else { + $export_data = "DELIMITER $$\n" + . $rtn_definition + . "$$\nDELIMITER ;\n"; + } + PMA_RTE_handleExport($export_data); } } diff --git a/libraries/rte/rte_list.lib.php b/libraries/rte/rte_list.lib.php index 7d08d984b736..85d27d6b541a 100644 --- a/libraries/rte/rte_list.lib.php +++ b/libraries/rte/rte_list.lib.php @@ -196,9 +196,24 @@ function PMA_RTN_getRowForList($routine, $rowclass = '') $retval .= " \n"; $retval .= " \n"; $retval .= " \n"; + + // this is for our purpose to decide whether to + // show the edit link or not, so we need the DEFINER for the routine + $where = "ROUTINE_SCHEMA " . PMA\libraries\Util::getCollateForIS() . "=" + . "'" . PMA\libraries\Util::sqlAddSlashes($db) . "' " + . "AND SPECIFIC_NAME='" . PMA\libraries\Util::sqlAddSlashes($routine['name']) . "'" + . "AND ROUTINE_TYPE='" . PMA\libraries\Util::sqlAddSlashes($routine['type']) . "'"; + $query = "SELECT `DEFINER` FROM INFORMATION_SCHEMA.ROUTINES WHERE $where;"; + $routine_definer = $GLOBALS['dbi']->fetchValue($query, 0, 0, $GLOBALS['controllink']); + + $curr_user = $GLOBALS['dbi']->getCurrentUser(); + // Since editing a procedure involved dropping and recreating, check also for // CREATE ROUTINE privilege to avoid lost procedures. - if (PMA\libraries\Util::currentUserHasPrivilege('CREATE ROUTINE', $db)) { + if ((PMA\libraries\Util::currentUserHasPrivilege('CREATE ROUTINE', $db) + && $curr_user == $routine_definer) + || $GLOBALS['is_superuser'] + ) { $retval .= ' \n"; $retval .= " \n"; - $retval .= ' ' . $titles['Export'] . "\n"; + if ((PMA\libraries\Util::currentUserHasPrivilege('CREATE ROUTINE', $db) + && $curr_user == $routine_definer) + || $GLOBALS['is_superuser'] + ) { + $retval .= ' ' . $titles['Export'] . "\n"; + } else { + $retval .= " {$titles['NoExport']}\n"; + } $retval .= " \n"; $retval .= " \n"; $retval .= ' fetchSingleRow($query); + $routine = $GLOBALS['dbi']->fetchSingleRow($query, 'ASSOC', $link); if (! $routine) { return false; @@ -595,13 +604,19 @@ function PMA_RTN_getDataFromName($name, $type, $all = true) $retval['item_name'] = $routine['SPECIFIC_NAME']; $retval['item_type'] = $routine['ROUTINE_TYPE']; - $parser = new SqlParser\Parser( - $GLOBALS['dbi']->getDefinition( + $definition + = $GLOBALS['dbi']->getDefinition( $db, $routine['ROUTINE_TYPE'], - $routine['SPECIFIC_NAME'] - ) - ); + $routine['SPECIFIC_NAME'], + $link + ); + + if ($definition == NULL) { + return false; + } + + $parser = new SqlParser\Parser($definition); /** * @var CreateStatement $stmt @@ -1283,7 +1298,7 @@ function PMA_RTN_handleExecute() if (! empty($_REQUEST['execute_routine']) && ! empty($_REQUEST['item_name'])) { // Build the queries $routine = PMA_RTN_getDataFromName( - $_REQUEST['item_name'], $_REQUEST['item_type'], false + $_REQUEST['item_name'], $_REQUEST['item_type'], false, true ); if ($routine === false) { $message = __('Error in processing request:') . ' '; @@ -1481,7 +1496,7 @@ function PMA_RTN_handleExecute() * Display the execute form for a routine. */ $routine = PMA_RTN_getDataFromName( - $_GET['item_name'], $_GET['item_type'], true + $_GET['item_name'], $_GET['item_type'], true, true ); if ($routine !== false) { $form = PMA_RTN_getExecuteForm($routine); diff --git a/libraries/rte/rte_words.lib.php b/libraries/rte/rte_words.lib.php index 18d757d25218..ff301874df87 100644 --- a/libraries/rte/rte_words.lib.php +++ b/libraries/rte/rte_words.lib.php @@ -31,6 +31,12 @@ function PMA_RTE_getWord($index) 'no_create' => __( 'You do not have the necessary privileges to create a routine' ), + 'no_edit' => __( + 'You do not have the necessary privileges to edit this routine' + ), + 'no_view' => __( + 'You do not have the necessary privileges to view/export this routine' + ), 'not_found' => __('No routine with name %1$s found in database %2$s'), 'nothing' => __('There are no routines to display.'), 'title' => __('Routines'), From 815bf44584f104d1616ca1d05a2aaba34580a418 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Thu, 8 Sep 2016 10:39:19 +0530 Subject: [PATCH 07/35] Fix error messages to suit better localization Signed-off-by: Deven Bansod --- libraries/rte/rte_export.lib.php | 3 +-- libraries/rte/rte_routines.lib.php | 3 +-- libraries/rte/rte_words.lib.php | 6 ++++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/rte/rte_export.lib.php b/libraries/rte/rte_export.lib.php index 19fa6dd0fb15..94b59ff5aaa6 100644 --- a/libraries/rte/rte_export.lib.php +++ b/libraries/rte/rte_export.lib.php @@ -44,8 +44,7 @@ function PMA_RTE_handleExport($export_data) } else { $_db = htmlspecialchars(PMA\libraries\Util::backquote($db)); $message = __('Error in processing request:') . ' ' - . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db) - . ' OR ' . PMA_RTE_getWord('no_view'); + . sprintf(PMA_RTE_getWord('no_view'), $item_name, $_db); $message = Message::error($message); if ($GLOBALS['is_ajax_request'] == true) { diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php index 21eb9bf9db88..2db6fcf79c87 100644 --- a/libraries/rte/rte_routines.lib.php +++ b/libraries/rte/rte_routines.lib.php @@ -155,13 +155,12 @@ function PMA_RTN_handleEditor() } else { $message = __('Error in processing request:') . ' '; $message .= sprintf( - PMA_RTE_getWord('not_found'), + PMA_RTE_getWord('no_edit'), htmlspecialchars( PMA\libraries\Util::backquote($_REQUEST['item_name']) ), htmlspecialchars(PMA\libraries\Util::backquote($db)) ); - $message .= ' OR ' . PMA_RTE_getWord('no_edit'); $message = Message::error($message); if ($GLOBALS['is_ajax_request']) { diff --git a/libraries/rte/rte_words.lib.php b/libraries/rte/rte_words.lib.php index ff301874df87..3205c2e7fb1e 100644 --- a/libraries/rte/rte_words.lib.php +++ b/libraries/rte/rte_words.lib.php @@ -32,10 +32,12 @@ function PMA_RTE_getWord($index) 'You do not have the necessary privileges to create a routine' ), 'no_edit' => __( - 'You do not have the necessary privileges to edit this routine' + 'No routine with name %1$s found in database %2$s. ' + . 'You might be lacking the necessary privileges to edit this routine' ), 'no_view' => __( - 'You do not have the necessary privileges to view/export this routine' + 'No routine with name %1$s found in database %2$s. ' + . 'You might be lacking the necessary privileges to view/export this routine' ), 'not_found' => __('No routine with name %1$s found in database %2$s'), 'nothing' => __('There are no routines to display.'), From 023ced3552c1e9d114539a7569623448c5878d96 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Thu, 15 Sep 2016 14:49:31 +0530 Subject: [PATCH 08/35] Don't use PMA_DROP_IMPORT on Table insert if it has Blob field If we force PMA_DROP_IMPORT on all pages, users can't use Chrome's drag-drop-files feature on Table Insert page with blob field Signed-off-by: Deven Bansod --- js/common.js | 16 ++++++++++++++++ libraries/insert_edit.lib.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/js/common.js b/js/common.js index 83733bf3eb9c..a962e884d991 100644 --- a/js/common.js +++ b/js/common.js @@ -298,6 +298,11 @@ PMA_DROP_IMPORT = { * @return void */ _dragenter : function (event) { + + if ($(".noDragDrop").length !== 0) { + return; + } + event.stopPropagation(); event.preventDefault(); if (!PMA_DROP_IMPORT._hasFiles(event)) { @@ -333,6 +338,10 @@ PMA_DROP_IMPORT = { * @return void */ _dragover: function (event) { + if ($(".noDragDrop").length !== 0) { + return; + } + event.stopPropagation(); event.preventDefault(); if (!PMA_DROP_IMPORT._hasFiles(event)) { @@ -348,6 +357,9 @@ PMA_DROP_IMPORT = { * @return void */ _dragleave: function (event) { + if ($(".noDragDrop").length !== 0) { + return; + } event.stopPropagation(); event.preventDefault(); var $pma_drop_handler = $(".pma_drop_handler"); @@ -408,6 +420,10 @@ PMA_DROP_IMPORT = { * @return void */ _drop: function (event) { + if ($(".noDragDrop").length !== 0) { + return; + } + var dbname = PMA_commonParams.get('db'); var server = PMA_commonParams.get('server'); diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index c9a538bb49d9..93a1fc9e910d 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -1129,7 +1129,7 @@ function PMA_getBinaryAndBlobColumn( $html_output .= '
' . ' '; list($html_out,) = PMA_getMaxUploadSize( $column, $biggest_max_file_size From 734b69b41873286931e96089de1d01b2f396cb98 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Fri, 16 Sep 2016 13:56:09 +0530 Subject: [PATCH 09/35] ChangeLog entry for #12487 Signed-off-by: Deven Bansod Conflicts: ChangeLog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 703d330f71d3..101fe0c864ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,6 +30,7 @@ phpMyAdmin - ChangeLog - issue #12473 Code can throw unhandled exception - issue #12550 Do not try to keep alive session even after expiry - issue #12512 Fixed rendering BBCode links in setup +- issue #12487 Drag and drop import prevents file dropping to blob column file selector on the insert tab 4.6.4 (2016-08-16) - issue [security] Weaknesses with cookie encryption, see PMASA-2016-29 From a52597f048fae7a0c89cd55fae6ad5bb0fe34d0e Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Thu, 15 Sep 2016 14:55:55 +0530 Subject: [PATCH 10/35] Include explaning statements near related code Signed-off-by: Deven Bansod --- js/common.js | 8 ++++++++ libraries/insert_edit.lib.php | 3 +++ 2 files changed, 11 insertions(+) diff --git a/js/common.js b/js/common.js index a962e884d991..c4331627153e 100644 --- a/js/common.js +++ b/js/common.js @@ -299,6 +299,8 @@ PMA_DROP_IMPORT = { */ _dragenter : function (event) { + // We don't want to prevent users from using + // browser's default drag-drop feature on some page(s) if ($(".noDragDrop").length !== 0) { return; } @@ -338,6 +340,8 @@ PMA_DROP_IMPORT = { * @return void */ _dragover: function (event) { + // We don't want to prevent users from using + // browser's default drag-drop feature on some page(s) if ($(".noDragDrop").length !== 0) { return; } @@ -357,6 +361,8 @@ PMA_DROP_IMPORT = { * @return void */ _dragleave: function (event) { + // We don't want to prevent users from using + // browser's default drag-drop feature on some page(s) if ($(".noDragDrop").length !== 0) { return; } @@ -420,6 +426,8 @@ PMA_DROP_IMPORT = { * @return void */ _drop: function (event) { + // We don't want to prevent users from using + // browser's default drag-drop feature on some page(s) if ($(".noDragDrop").length !== 0) { return; } diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php index 93a1fc9e910d..2fca16a83eaf 100644 --- a/libraries/insert_edit.lib.php +++ b/libraries/insert_edit.lib.php @@ -1126,6 +1126,9 @@ function PMA_getBinaryAndBlobColumn( $html_output .= sprintf($fields_type_html, $fields_type_val); if ($is_upload && $column['is_blob'] && !$readOnly) { + // We don't want to prevent users from using + // browser's default drag-drop feature on some page(s), + // so we add noDragDrop class to the input $html_output .= '
' . ' Date: Thu, 15 Sep 2016 21:11:56 +0530 Subject: [PATCH 11/35] Fixed tests Signed-off-by: Deven Bansod --- test/libraries/PMA_insert_edit_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/libraries/PMA_insert_edit_test.php b/test/libraries/PMA_insert_edit_test.php index 5149c74811d5..a61d1bf1d452 100644 --- a/test/libraries/PMA_insert_edit_test.php +++ b/test/libraries/PMA_insert_edit_test.php @@ -1132,7 +1132,7 @@ public function testGetBinaryAndBlobColumn() . 'name="fieldsb" value="" />' . '
 (Max: 64KiB)' . "\n", + . 'field noDragDrop" id="field_1_3" size="10" c/> (Max: 64KiB)' . "\n", $result ); @@ -1190,7 +1190,7 @@ public function testGetBinaryAndBlobColumn() . 'cols="1" dir="/" id="field_1_3" c tabindex="3" data-type="HEX">' . '' . '
 (Max: 64KiB)' . "\n", + . 'field noDragDrop" id="field_1_3" size="10" c/> (Max: 64KiB)' . "\n", $result ); From b054aa70ef443929484f087f459d4d856fcabaa5 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Thu, 15 Sep 2016 12:10:17 +0530 Subject: [PATCH 12/35] Uncheck the Add CREATE PROCEDURE / FUNCTION etc. checkbox for a selective export User can always check it if he/she wants to export the procs,funcs etc. too Signed-off-by: Deven Bansod --- js/export.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/js/export.js b/js/export.js index 762ba4166e45..09fedd2af04b 100644 --- a/js/export.js +++ b/js/export.js @@ -540,6 +540,16 @@ function toggle_table_select(row) { } } +function handleAddProcCheckbox() { + if ($('#table_structure_all').is(':checked') === true + && $('#table_data_all').is(':checked') === true + ) { + $('#checkbox_sql_procedure_function').prop('checked', true); + } else { + $('#checkbox_sql_procedure_function').prop('checked', false); + } +} + AJAX.registerOnload('export.js', function () { /** * For SQL plugin, if "CREATE TABLE options" is checked/unchecked, check/uncheck each of its sub-options @@ -579,26 +589,31 @@ AJAX.registerOnload('export.js', function () { $('input[name="table_select[]"]').on('change', function() { toggle_table_select($(this).closest('tr')); check_table_select_all(); + handleAddProcCheckbox(); }); $('input[name="table_structure[]"]').on('change', function() { check_table_selected($(this).closest('tr')); check_table_select_all(); + handleAddProcCheckbox(); }); $('input[name="table_data[]"]').on('change', function() { check_table_selected($(this).closest('tr')); check_table_select_all(); + handleAddProcCheckbox(); }); $('#table_structure_all').on('change', function() { toggle_table_select_all_str(); check_selected_tables(); + handleAddProcCheckbox(); }); $('#table_data_all').on('change', function() { toggle_table_select_all_data(); check_selected_tables(); + handleAddProcCheckbox(); }); if ($("input[name='export_type']").val() == 'database') { @@ -805,6 +820,8 @@ AJAX.registerOnload('export.js', function () { toggle_quick_or_custom(); toggle_structure_data_opts(); toggle_sql_include_comments(); + check_table_select_all(); + handleAddProcCheckbox(); /** * Initially disables the "Dump some row(s)" sub-options From 4f1432eb2fe6a25efbf740c9f712d4454e109969 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Fri, 16 Sep 2016 13:57:26 +0530 Subject: [PATCH 13/35] ChangeLog entry for #12300 Signed-off-by: Deven Bansod Conflicts: ChangeLog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 703d330f71d3..e5e32418c50d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,6 +30,7 @@ phpMyAdmin - ChangeLog - issue #12473 Code can throw unhandled exception - issue #12550 Do not try to keep alive session even after expiry - issue #12512 Fixed rendering BBCode links in setup +- issue #12300 Export selective tables by-default dumps Events also 4.6.4 (2016-08-16) - issue [security] Weaknesses with cookie encryption, see PMASA-2016-29 From e8d07e3783f0a1b7140ba3ee6a3b2e472e210b65 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Thu, 15 Sep 2016 00:52:14 +0530 Subject: [PATCH 14/35] Allow vertical scrolling to read longer text values in grid editing Fix #12554 Signed-off-by: Deven Bansod --- themes/original/css/common.css.php | 3 ++- themes/pmahomme/css/common.css.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/themes/original/css/common.css.php b/themes/original/css/common.css.php index 2b17bcd491c4..13b4b3debcee 100644 --- a/themes/original/css/common.css.php +++ b/themes/original/css/common.css.php @@ -2321,7 +2321,8 @@ } .cEdit .edit_box { - overflow: hidden; + overflow-x: hidden; + overflow-y: scroll; padding: 0; } diff --git a/themes/pmahomme/css/common.css.php b/themes/pmahomme/css/common.css.php index 50f6d22a861f..a4177400f34a 100644 --- a/themes/pmahomme/css/common.css.php +++ b/themes/pmahomme/css/common.css.php @@ -2873,7 +2873,8 @@ } .cEdit .edit_box { - overflow: hidden; + overflow-x: hidden; + overflow-y: scroll; padding: 0; margin: 0; } From b6952bbe55a9fa727482a47533cc066c5e36f189 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Fri, 16 Sep 2016 13:59:00 +0530 Subject: [PATCH 15/35] ChangeLog entry for #12554 Signed-off-by: Deven Bansod Conflicts: ChangeLog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 703d330f71d3..b2c4eec55f25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,6 +30,7 @@ phpMyAdmin - ChangeLog - issue #12473 Code can throw unhandled exception - issue #12550 Do not try to keep alive session even after expiry - issue #12512 Fixed rendering BBCode links in setup +- issue #12554 Absence of scrolling makes it impossible to read longer text values in grid editing 4.6.4 (2016-08-16) - issue [security] Weaknesses with cookie encryption, see PMASA-2016-29 From ea90f285517e79f6db80b5038e563f483269839b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 16 Sep 2016 10:34:55 +0200 Subject: [PATCH 16/35] Changelog for #12548 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 703d330f71d3..d65567cf9fdb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,6 +30,8 @@ phpMyAdmin - ChangeLog - issue #12473 Code can throw unhandled exception - issue #12550 Do not try to keep alive session even after expiry - issue #12512 Fixed rendering BBCode links in setup +- issue #12518 Fixed copy of table with generated columns +- issue #12221 Fixed export of table with generated columns 4.6.4 (2016-08-16) - issue [security] Weaknesses with cookie encryption, see PMASA-2016-29 From 350be95a53d496ea774d35c8a9d02bd377f3b0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 16 Sep 2016 10:37:22 +0200 Subject: [PATCH 17/35] Changelog entry for #12553 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index d65567cf9fdb..36b8a5e4cc2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -32,6 +32,7 @@ phpMyAdmin - ChangeLog - issue #12512 Fixed rendering BBCode links in setup - issue #12518 Fixed copy of table with generated columns - issue #12221 Fixed export of table with generated columns +- issue #12320 Copying a user does not copy usergroup 4.6.4 (2016-08-16) - issue [security] Weaknesses with cookie encryption, see PMASA-2016-29 From b18426f887ef1958c696a0e6c8404dfd1b51673c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 16 Sep 2016 11:20:42 +0200 Subject: [PATCH 18/35] Correctly reference Math.min (issue #12550) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- js/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/functions.js b/js/functions.js index 9fa445f314a8..a6587bbad133 100644 --- a/js/functions.js +++ b/js/functions.js @@ -906,7 +906,7 @@ AJAX.registerOnload('functions.js', function () { var remaining = PMA_commonParams.get('LoginCookieValidity') - _idleSecondsCounter; if (remaining > 5) { // max value for setInterval() function - var interval = min(remaining * 1000, Math.pow(2, 31) - 1); + var interval = Math.min(remaining * 1000, Math.pow(2, 31) - 1); updateTimeout = window.setTimeout(UpdateIdleTime, interval); } else if (remaining > 0) { // We're close to session expiry From bd9bbc4b4dc2121a3c5f3a2b7bf7bfc60559f15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 16 Sep 2016 11:38:13 +0200 Subject: [PATCH 19/35] Document test removal suggestion for production usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue #12547 Signed-off-by: Michal Čihař --- doc/setup.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/setup.rst b/doc/setup.rst index 66eb0469e45a..474a93e86661 100644 --- a/doc/setup.rst +++ b/doc/setup.rst @@ -756,6 +756,7 @@ are always ways to make your installation more secure: * Serve phpMyAdmin on HTTPS only. Preferably, you should use HSTS as well, so that you're protected from protocol downgrade attacks. +* Remove the ``test`` directory from phpMyAdmin, unless you are developing and need test suite. * Remove the ``setup`` directory from phpMyAdmin, you will probably not use it after the initial setup. * Properly choose an authentication method - :ref:`cookie` From 1d09172f14e1b99e0daf9ccc08df5a9b6ccf1191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 16 Sep 2016 11:49:53 +0200 Subject: [PATCH 20/35] Turn OpenDocument wrapper to a class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- libraries/OpenDocument.php | 174 +++++++++++++++++++ libraries/opendocument.lib.php | 167 ------------------ libraries/plugins/export/ExportOds.php | 6 +- libraries/plugins/export/ExportOdt.php | 6 +- test/classes/plugin/export/ExportOdsTest.php | 1 - test/classes/plugin/export/ExportOdtTest.php | 8 +- 6 files changed, 185 insertions(+), 177 deletions(-) create mode 100644 libraries/OpenDocument.php delete mode 100644 libraries/opendocument.lib.php diff --git a/libraries/OpenDocument.php b/libraries/OpenDocument.php new file mode 100644 index 000000000000..08e6608867cd --- /dev/null +++ b/libraries/OpenDocument.php @@ -0,0 +1,174 @@ + addFile($mime, 'mimetype'); + $zipfile -> addFile($data, 'content.xml'); + $zipfile -> addFile( + '' + . '' + . '' + . 'phpMyAdmin ' . PMA_VERSION . '' + . 'phpMyAdmin ' . PMA_VERSION + . '' + . '' . strftime('%Y-%m-%dT%H:%M:%S') + . '' + . '' + . '', + 'meta.xml' + ); + $zipfile -> addFile( + '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '', + 'styles.xml' + ); + $zipfile -> addFile( + '' + . '' + . '' + . '' + . '' + . '' + . '', + 'META-INF/manifest.xml' + ); + return $zipfile -> file(); + } +} diff --git a/libraries/opendocument.lib.php b/libraries/opendocument.lib.php deleted file mode 100644 index 71305d86dff2..000000000000 --- a/libraries/opendocument.lib.php +++ /dev/null @@ -1,167 +0,0 @@ - addFile($mime, 'mimetype'); - $zipfile -> addFile($data, 'content.xml'); - $zipfile -> addFile( - '' - . '' - . '' - . 'phpMyAdmin ' . PMA_VERSION . '' - . 'phpMyAdmin ' . PMA_VERSION - . '' - . '' . strftime('%Y-%m-%dT%H:%M:%S') - . '' - . '' - . '', - 'meta.xml' - ); - $zipfile -> addFile( - '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '', - 'styles.xml' - ); - $zipfile -> addFile( - '' - . '' - . '' - . '' - . '' - . '' - . '', - 'META-INF/manifest.xml' - ); - return $zipfile -> file(); -} diff --git a/libraries/plugins/export/ExportOds.php b/libraries/plugins/export/ExportOds.php index 8ee621c515b1..1d96290ba619 100644 --- a/libraries/plugins/export/ExportOds.php +++ b/libraries/plugins/export/ExportOds.php @@ -16,9 +16,9 @@ use PMA\libraries\properties\options\groups\OptionsPropertyRootGroup; use PMA\libraries\DatabaseInterface; use PMA\libraries\properties\options\items\TextPropertyItem; +use PMA\libraries\OpenDocument; $GLOBALS['ods_buffer'] = ''; -require_once 'libraries/opendocument.lib.php'; /** * Handles the export for the ODS class @@ -91,7 +91,7 @@ public function exportHeader() { $GLOBALS['ods_buffer'] .= '' . '' + . OpenDocument::$ns . 'office:version="1.0">' . '' . '' @@ -149,7 +149,7 @@ public function exportFooter() . '' . ''; if (!PMA_exportOutputHandler( - PMA_createOpenDocument( + OpenDocument::create( 'application/vnd.oasis.opendocument.spreadsheet', $GLOBALS['ods_buffer'] ) diff --git a/libraries/plugins/export/ExportOdt.php b/libraries/plugins/export/ExportOdt.php index 152619cecda3..9c1f73772d93 100644 --- a/libraries/plugins/export/ExportOdt.php +++ b/libraries/plugins/export/ExportOdt.php @@ -17,9 +17,9 @@ use PMA\libraries\Util; use PMA\libraries\properties\options\items\RadioPropertyItem; use PMA\libraries\properties\options\items\TextPropertyItem; +use PMA\libraries\OpenDocument; $GLOBALS['odt_buffer'] = ''; -require_once 'libraries/opendocument.lib.php'; /** * Handles the export for the ODT class @@ -148,7 +148,7 @@ public function exportHeader() { $GLOBALS['odt_buffer'] .= '' . '' + . OpenDocument::$ns . 'office:version="1.0">' . '' . ''; @@ -166,7 +166,7 @@ public function exportFooter() . '' . ''; if (!PMA_exportOutputHandler( - PMA_createOpenDocument( + OpenDocument::create( 'application/vnd.oasis.opendocument.text', $GLOBALS['odt_buffer'] ) diff --git a/test/classes/plugin/export/ExportOdsTest.php b/test/classes/plugin/export/ExportOdsTest.php index b458b0d7cc81..4a4d1d351f19 100644 --- a/test/classes/plugin/export/ExportOdsTest.php +++ b/test/classes/plugin/export/ExportOdsTest.php @@ -11,7 +11,6 @@ require_once 'libraries/plugins/export/ExportOds.php'; require_once 'libraries/export.lib.php'; require_once 'libraries/config.default.php'; -require_once 'libraries/opendocument.lib.php'; require_once 'test/PMATestCase.php'; /** diff --git a/test/classes/plugin/export/ExportOdtTest.php b/test/classes/plugin/export/ExportOdtTest.php index f720be14897b..6952e47ec193 100644 --- a/test/classes/plugin/export/ExportOdtTest.php +++ b/test/classes/plugin/export/ExportOdtTest.php @@ -313,14 +313,16 @@ public function testSetProperties() */ public function testExportHeader() { - $GLOBALS['OpenDocumentNS'] = "ODNS"; - $this->assertTrue( $this->object->exportHeader() ); $this->assertContains( - "assertContains( + "office:version", $GLOBALS['odt_buffer'] ); } From 0ebdd9b6b53eb39d9e7c2255a31a14f357251ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 16 Sep 2016 12:00:32 +0200 Subject: [PATCH 21/35] Use environment for configuring tests only on CLI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://httpoxy.org/ for possible problems. Signed-off-by: Michal Čihař --- test/bootstrap-dist.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/bootstrap-dist.php b/test/bootstrap-dist.php index 6eb190694465..f83ad7a04925 100644 --- a/test/bootstrap-dist.php +++ b/test/bootstrap-dist.php @@ -47,12 +47,14 @@ 'TESTSUITE_FULL' => '', 'CI_MODE' => '' ); -foreach ($test_defaults as $varname => $defvalue) { - $envvar = getenv($varname); - if ($envvar) { - $GLOBALS[$varname] = $envvar; - } else { - $GLOBALS[$varname] = $defvalue; +if (PHP_SAPI == 'cli') { + foreach ($test_defaults as $varname => $defvalue) { + $envvar = getenv($varname); + if ($envvar) { + $GLOBALS[$varname] = $envvar; + } else { + $GLOBALS[$varname] = $defvalue; + } } } @@ -70,7 +72,7 @@ // Set proxy information from env, if available $http_proxy = getenv('http_proxy'); -if ($http_proxy && ($url_info = parse_url($http_proxy))) { +if (PHP_SAPI == 'cli' && $http_proxy && ($url_info = parse_url($http_proxy))) { define('PROXY_URL', $url_info['host'] . ':' . $url_info['port']); define('PROXY_USER', empty($url_info['user']) ? '' : $url_info['user']); define('PROXY_PASS', empty($url_info['pass']) ? '' : $url_info['pass']); From ba51eb95b695227fd498a329be0cfe6975de0905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 16 Sep 2016 13:12:10 +0200 Subject: [PATCH 22/35] Fix operator placement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- libraries/OpenDocument.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/OpenDocument.php b/libraries/OpenDocument.php index 08e6608867cd..b731bcaac097 100644 --- a/libraries/OpenDocument.php +++ b/libraries/OpenDocument.php @@ -18,12 +18,12 @@ class OpenDocument { - public static $ns = 'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" ' - . 'xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" ' - . 'xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" ' - . 'xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" ' - . 'xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" ' - . 'xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" '; + public static $ns = 'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" ' . + 'xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" ' . + 'xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" ' . + 'xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" ' . + 'xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" ' . + 'xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" '; /** * Minimalistic creator of OASIS OpenDocument From a2ab6a04afc0214ce16b4f04f67eca28739f292d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 16 Sep 2016 13:21:20 +0200 Subject: [PATCH 23/35] Define namespace as constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also use PHP 5.5 compatible way of defining static variable. Signed-off-by: Michal Čihař --- libraries/OpenDocument.php | 16 +++++++++------- libraries/plugins/export/ExportOds.php | 2 +- libraries/plugins/export/ExportOdt.php | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libraries/OpenDocument.php b/libraries/OpenDocument.php index b731bcaac097..d649fa92280d 100644 --- a/libraries/OpenDocument.php +++ b/libraries/OpenDocument.php @@ -18,12 +18,14 @@ class OpenDocument { - public static $ns = 'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" ' . - 'xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" ' . - 'xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" ' . - 'xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" ' . - 'xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" ' . - 'xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" '; + const NS = << addFile( '' - . '' . '' . '' . '' + . OpenDocument::NS . 'office:version="1.0">' . '' . '' diff --git a/libraries/plugins/export/ExportOdt.php b/libraries/plugins/export/ExportOdt.php index 9c1f73772d93..3c51b5beec91 100644 --- a/libraries/plugins/export/ExportOdt.php +++ b/libraries/plugins/export/ExportOdt.php @@ -148,7 +148,7 @@ public function exportHeader() { $GLOBALS['odt_buffer'] .= '' . '' + . OpenDocument::NS . 'office:version="1.0">' . '' . ''; From 541dbd3a5a5dddddec4aba249489f7d1491c98da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 16 Sep 2016 14:00:50 +0200 Subject: [PATCH 24/35] Do not store uid in tarballs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #12560 Signed-off-by: Michal Čihař --- scripts/create-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create-release.sh b/scripts/create-release.sh index c69be0c17a9a..0f54b69da7e0 100755 --- a/scripts/create-release.sh +++ b/scripts/create-release.sh @@ -279,7 +279,7 @@ for kit in $KITS ; do tbz|tgz|txz) if [ ! -f $name.tar ] ; then echo "* Creating $name.tar" - tar cf $name.tar $name + tar --owner=root --group=root --numeric-owner -cf $name.tar $name fi if [ $comp = tbz ] ; then echo "* Creating $name.tar.bz2" From 91ffece4a8081ead5c091b46ca77bb88d8c4faac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 16 Sep 2016 14:01:56 +0200 Subject: [PATCH 25/35] Sort files in tar by name (issue #12560) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- scripts/create-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create-release.sh b/scripts/create-release.sh index 0f54b69da7e0..b0c3d5efcde2 100755 --- a/scripts/create-release.sh +++ b/scripts/create-release.sh @@ -279,7 +279,7 @@ for kit in $KITS ; do tbz|tgz|txz) if [ ! -f $name.tar ] ; then echo "* Creating $name.tar" - tar --owner=root --group=root --numeric-owner -cf $name.tar $name + tar --owner=root --group=root --numeric-owner --sort=name -cf $name.tar $name fi if [ $comp = tbz ] ; then echo "* Creating $name.tar.bz2" From a588880750b50764217f3379af7beac9f9201769 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Fri, 16 Sep 2016 18:33:28 +0530 Subject: [PATCH 26/35] Special handling for radio fields after cloning on tbl insert page Fix #12272 Signed-off-by: Deven Bansod --- js/tbl_change.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/tbl_change.js b/js/tbl_change.js index eeba3b51d71b..6ae5948aa6a2 100644 --- a/js/tbl_change.js +++ b/js/tbl_change.js @@ -553,6 +553,7 @@ AJAX.registerOnload('tbl_change.js', function () { // handle input text fields and textareas if ($this_element.is('.textfield') || $this_element.is('.char')) { // do not remove the 'value' attribute for ENUM columns + // special handling for radio fields after updating ids to unique - see below if ($this_element.closest('tr').find('span.column_type').html() != 'enum') { $this_element.val($this_element.closest('tr').find('span.default_value').html()); } @@ -675,6 +676,15 @@ AJAX.registerOnload('tbl_change.js', function () { $(this).attr('tabindex', tabindex); // update the IDs of textfields to ensure that they are unique $(this).attr('id', "field_" + tabindex + "_3"); + + // special handling for radio fields after updating ids to unique + if ($(this).closest('tr').find('span.column_type').html() === 'enum') { + if ($(this).val() === $(this).closest('tr').find('span.default_value').html()) { + $(this).prop('checked', true); + } else { + $(this).prop('checked', false); + } + } }); $('.control_at_footer') .each(function () { From 14340f9c31977bbd19763f573a1c20366f22d089 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Fri, 16 Sep 2016 18:37:03 +0530 Subject: [PATCH 27/35] ChangeLog entry for #12272 Signed-off-by: Deven Bansod --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 703d330f71d3..4aa479788b55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,6 +30,7 @@ phpMyAdmin - ChangeLog - issue #12473 Code can throw unhandled exception - issue #12550 Do not try to keep alive session even after expiry - issue #12512 Fixed rendering BBCode links in setup +- issue #12272 Adding a new row with default enum goes to no selection when you want to add more then 2 rows 4.6.4 (2016-08-16) - issue [security] Weaknesses with cookie encryption, see PMASA-2016-29 From 3fc7fc0c1b40a0d7c17981588b2f6b050c15458a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 16 Sep 2016 15:33:10 +0200 Subject: [PATCH 28/35] Validate branch and version strings on releasing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- scripts/create-release.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/create-release.sh b/scripts/create-release.sh index b0c3d5efcde2..c4851ca8434d 100755 --- a/scripts/create-release.sh +++ b/scripts/create-release.sh @@ -59,9 +59,17 @@ while [ $# -gt 0 ] ; do ;; *) if [ -z "$version" ] ; then - version="$1" + version=`echo $1 | tr -d -c '0-9a-z.-'` + if [ "x$version" != "x$1" ] ; then + echo "Invalid version: $1" + exit 1 + fi elif [ -z "$branch" ] ; then - branch="$1" + branch=`echo $1 | tr -d -c '0-9A-Za-z_-'` + if [ "x$branch" != "x$1" ] ; then + echo "Invalid branch: $1" + exit 1 + fi else echo "Unknown parameter: $1!" exit 1 From 2fc2c25aaf823ce78040667e1c9bb6ce68ce62e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 16 Sep 2016 15:59:42 +0200 Subject: [PATCH 29/35] Fix documentation to match state after PMASA-2016-54 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- doc/transformations.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/transformations.rst b/doc/transformations.rst index fe68a8dab3ee..7b5f1a0087ec 100644 --- a/doc/transformations.rst +++ b/doc/transformations.rst @@ -117,8 +117,8 @@ libraries/plugins/transformations/TEMPLATE\_ABSTRACT files for adding your own transformation plug-in. You can also generate a new transformation plug-in (with or without the abstract transformation class), by using -:file:`libraries/plugins/transformations/generator_plugin.sh` or -:file:`libraries/plugins/transformations/generator_main_class.sh`. +:file:`scripts/transformations_generator_plugin.sh` or +:file:`scripts/transformations_generator_main_class.sh`. The applyTransformation() method always gets passed three variables: From ea5870bb9b90b48865e4d28609ccb1b4ecb410d8 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Sun, 18 Sep 2016 12:04:38 +0530 Subject: [PATCH 30/35] Fix class name in export test comments Signed-off-by: Deven Bansod --- test/libraries/PMA_export_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/libraries/PMA_export_test.php b/test/libraries/PMA_export_test.php index cf4e3dc770e4..3accde572536 100644 --- a/test/libraries/PMA_export_test.php +++ b/test/libraries/PMA_export_test.php @@ -14,7 +14,7 @@ require_once 'libraries/export.lib.php'; /** - * class PMA_DisplayExport_Test + * class PMA_Export_Test * * this class is for testing export.lib.php functions * From d800fc16791ad389629935634a7fe587864e0f46 Mon Sep 17 00:00:00 2001 From: dingo thirteen Date: Sun, 18 Sep 2016 17:57:22 +0000 Subject: [PATCH 31/35] Translated using Weblate (Dutch) Currently translated at 100.0% (3206 of 3206 strings) [CI skip] --- po/nl.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/po/nl.po b/po/nl.po index 6b27290d1bd1..df543bf5c200 100644 --- a/po/nl.po +++ b/po/nl.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.6.5-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2016-08-17 11:29+0200\n" -"PO-Revision-Date: 2016-08-17 10:19+0000\n" +"PO-Revision-Date: 2016-09-18 17:57+0000\n" "Last-Translator: dingo thirteen \n" "Language-Team: Dutch " "\n" @@ -13,7 +13,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 2.8-dev\n" +"X-Generator: Weblate 2.9-dev\n" #: changelog.php:38 license.php:33 #, php-format @@ -9354,7 +9354,7 @@ msgstr "Startpagina" #: libraries/navigation/NavigationHeader.php:170 msgid "Log out" -msgstr "Aanmelden" +msgstr "Afmelden" #: libraries/navigation/NavigationHeader.php:172 msgid "Empty session data" From 3992bd65be6db0afc768052c54b70156eec1d711 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Sun, 18 Sep 2016 15:45:30 +0000 Subject: [PATCH 32/35] Translated using Weblate (German) Currently translated at 99.8% (3201 of 3206 strings) [CI skip] --- po/de.po | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/po/de.po b/po/de.po index e1e24feb3af3..65ba26dcbf22 100644 --- a/po/de.po +++ b/po/de.po @@ -4,16 +4,16 @@ msgstr "" "Project-Id-Version: phpMyAdmin-docs 4.0.0-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2016-08-17 11:29+0200\n" -"PO-Revision-Date: 2016-08-16 18:53+0000\n" -"Last-Translator: Axel Rindle \n" -"Language-Team: German \n" +"PO-Revision-Date: 2016-09-18 15:45+0000\n" +"Last-Translator: Deven Bansod \n" +"Language-Team: German " +"\n" "Language: de\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 2.8-dev\n" +"X-Generator: Weblate 2.9-dev\n" #: changelog.php:38 license.php:33 #, php-format @@ -11494,7 +11494,7 @@ msgid "" "This server is not configured as master in a replication process. Would you " "like to
configure it?" msgstr "" -"Dieser Server ist als nicht Master in einem Replikations-Prozess " +"Dieser Server ist nicht als Master in einem Replikations-Prozess " "konfiguriert. Möchten Sie ihn konfigurieren?" #: libraries/replication_gui.lib.php:400 From 523b2f3ba9d6790319935f9257e330456ea7e9f6 Mon Sep 17 00:00:00 2001 From: dingo thirteen Date: Sun, 18 Sep 2016 17:57:25 +0000 Subject: [PATCH 33/35] Translated using Weblate (Dutch) Currently translated at 99.9% (3216 of 3219 strings) [CI skip] --- po/nl.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/po/nl.po b/po/nl.po index 2d45fa3b9a73..684520e6c68e 100644 --- a/po/nl.po +++ b/po/nl.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.7.0-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2016-08-17 11:28+0200\n" -"PO-Revision-Date: 2016-08-17 10:19+0000\n" +"PO-Revision-Date: 2016-09-18 17:57+0000\n" "Last-Translator: dingo thirteen \n" "Language-Team: Dutch " "\n" @@ -13,7 +13,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 2.8-dev\n" +"X-Generator: Weblate 2.9-dev\n" #: changelog.php:38 license.php:33 #, fuzzy, php-format @@ -9238,7 +9238,7 @@ msgstr "Startpagina" #: libraries/navigation/NavigationHeader.php:171 msgid "Log out" -msgstr "Aanmelden" +msgstr "Afmelden" #: libraries/navigation/NavigationHeader.php:173 msgid "Empty session data" From dc43daf34e47e0005a911df385b0d47e8da67825 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Sun, 18 Sep 2016 15:45:36 +0000 Subject: [PATCH 34/35] Translated using Weblate (German) Currently translated at 99.2% (3196 of 3219 strings) [CI skip] --- po/de.po | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/po/de.po b/po/de.po index 32194a272690..b58c5d6d7b10 100644 --- a/po/de.po +++ b/po/de.po @@ -4,16 +4,16 @@ msgstr "" "Project-Id-Version: phpMyAdmin-docs 4.0.0-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2016-08-17 11:28+0200\n" -"PO-Revision-Date: 2016-08-16 18:53+0000\n" -"Last-Translator: Axel Rindle \n" -"Language-Team: German \n" +"PO-Revision-Date: 2016-09-18 15:45+0000\n" +"Last-Translator: Deven Bansod \n" +"Language-Team: German " +"\n" "Language: de\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 2.8-dev\n" +"X-Generator: Weblate 2.9-dev\n" #: changelog.php:38 license.php:33 #, fuzzy, php-format @@ -11375,7 +11375,7 @@ msgid "" "This server is not configured as master in a replication process. Would you " "like to configure it?" msgstr "" -"Dieser Server ist als nicht Master in einem Replikations-Prozess " +"Dieser Server ist nicht als Master in einem Replikations-Prozess " "konfiguriert. Möchten Sie ihn konfigurieren?" #: libraries/replication_gui.lib.php:401 From f7f03127f7486281ccd4335f8137bec19ebb7254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 19 Sep 2016 11:34:43 +0200 Subject: [PATCH 35/35] Store create options in serapate array instead of polluting global namespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is just a minor cleanup to avoid possible problems when MySQL create table options would collide with our variable names. See also issue #12567 Signed-off-by: Michal Čihař --- libraries/tbl_info.inc.php | 13 +++++++------ tbl_operations.php | 33 ++++++++++++++++----------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/libraries/tbl_info.inc.php b/libraries/tbl_info.inc.php index 1ce1e84b9495..09db3b692ef8 100644 --- a/libraries/tbl_info.inc.php +++ b/libraries/tbl_info.inc.php @@ -85,25 +85,26 @@ ? $showtable['Auto_increment'] : ''; - $create_options = isset($showtable['Create_options']) + $create_options_tmp = isset($showtable['Create_options']) ? explode(' ', $showtable['Create_options']) : array(); + $create_options = array(); // export create options by its name as variables into global namespace // f.e. pack_keys=1 becomes available as $pack_keys with value of '1' unset($pack_keys); - foreach ($create_options as $each_create_option) { + foreach ($create_options_tmp as $each_create_option) { $each_create_option = explode('=', $each_create_option); if (isset($each_create_option[1])) { // ensure there is no ambiguity for PHP 5 and 7 - ${$each_create_option[0]} = $each_create_option[1]; + $create_options[$each_create_option[0]] = $each_create_option[1]; } } // we need explicit DEFAULT value here (different from '0') - $pack_keys = (! isset($pack_keys) || mb_strlen($pack_keys) == 0) + $create_options['pack_keys'] = (! isset($create_options['pack_keys']) || strlen($create_options['pack_keys']) == 0) ? 'DEFAULT' - : $pack_keys; - unset($create_options, $each_create_option); + : $create_options['pack_keys']; + unset($create_options_tmp, $each_create_option); } else { $pack_keys = $row_format = null; }// end if diff --git a/tbl_operations.php b/tbl_operations.php index 373f422a4757..4f3b66760e48 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -64,12 +64,12 @@ // the value for transactional can be implicit // (no create option found, in this case it means 1) // or explicit (option found with a value of 0 or 1) - // ($transactional may have been set by libraries/tbl_info.inc.php, + // ($create_options['transactional'] may have been set by libraries/tbl_info.inc.php, // from the $create_options) - $transactional = (isset($transactional) && $transactional == '0') + $create_options['transactional'] = (isset($create_options['transactional']) && $create_options['transactional'] == '0') ? '0' : '1'; - $page_checksum = (isset($page_checksum)) ? $page_checksum : ''; + $create_options['page_checksum'] = (isset($create_options['page_checksum'])) ? $create_options['page_checksum'] : ''; } $reread_info = false; @@ -137,24 +137,24 @@ ) = PMA_setGlobalVariablesForEngine($new_tbl_storage_engine); if ($is_aria) { - $transactional = (isset($transactional) && $transactional == '0') + $create_options['transactional'] = (isset($create_options['transactional']) && $create_options['transactional'] == '0') ? '0' : '1'; - $page_checksum = (isset($page_checksum)) ? $page_checksum : ''; + $create_options['page_checksum'] = (isset($create_options['page_checksum'])) ? $create_options['page_checksum'] : ''; } } else { $new_tbl_storage_engine = ''; } $table_alters = PMA_getTableAltersArray( - $is_myisam_or_aria, $is_isam, $pack_keys, - (empty($checksum) ? '0' : '1'), + $is_myisam_or_aria, $is_isam, $create_options['pack_keys'], + (empty($create_options['checksum']) ? '0' : '1'), $is_aria, - ((isset($page_checksum)) ? $page_checksum : ''), - (empty($delay_key_write) ? '0' : '1'), - $is_innodb, $is_pbxt, $row_format, + ((isset($create_options['page_checksum'])) ? $create_options['page_checksum'] : ''), + (empty($create_options['delay_key_write']) ? '0' : '1'), + $is_innodb, $is_pbxt, $create_options['row_format'], $new_tbl_storage_engine, - ((isset($transactional) && $transactional == '0') ? '0' : '1'), + ((isset($create_options['transactional']) && $create_options['transactional'] == '0') ? '0' : '1'), $tbl_collation ); @@ -199,7 +199,6 @@ // to avoid showing the old value (for example the AUTO_INCREMENT) after // a change, clear the cache $GLOBALS['dbi']->clearTableCache(); - $page_checksum = $checksum = $delay_key_write = 0; include 'libraries/tbl_info.inc.php'; } unset($reread_info); @@ -335,12 +334,12 @@ $response->addHTML( PMA_getTableOptionDiv( $comment, $tbl_collation, $tbl_storage_engine, - $is_myisam_or_aria, $is_isam, $pack_keys, + $is_myisam_or_aria, $is_isam, $create_options['pack_keys'], $auto_increment, - (empty($delay_key_write) ? '0' : '1'), - ((isset($transactional) && $transactional == '0') ? '0' : '1'), - ((isset($page_checksum)) ? $page_checksum : ''), - $is_innodb, $is_pbxt, $is_aria, (empty($checksum) ? '0' : '1') + (empty($create_options['delay_key_write']) ? '0' : '1'), + ((isset($create_options['transactional']) && $create_options['transactional'] == '0') ? '0' : '1'), + ((isset($create_options['page_checksum'])) ? $create_options['page_checksum'] : ''), + $is_innodb, $is_pbxt, $is_aria, (empty($create_options['checksum']) ? '0' : '1') ) );