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] 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 1ce1e84b94..09db3b692e 100644 --- a/libraries/tbl_info.inc.php +++ b/libraries/tbl_info.inc.php @@ -85,25 +85,26 @@ if ($showtable) { ? $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 373f422a47..4f3b66760e 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -64,12 +64,12 @@ if ($is_aria) { // 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 @@ if (isset($_REQUEST['submitoptions'])) { ) = 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 @@ if ($reread_info) { // 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 @@ if (mb_strstr($show_comment, '; InnoDB free') === false) { $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') ) );