From cab63eae591d358cda3b3b63e21e08175f95dfcd Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 27 May 2023 12:26:52 +0100 Subject: [PATCH 01/11] $GLOBALS['show_comment'] Signed-off-by: Kamil Tekiela --- .../Controllers/Table/OperationsController.php | 17 ++++++++--------- psalm-baseline.xml | 2 -- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/libraries/classes/Controllers/Table/OperationsController.php b/libraries/classes/Controllers/Table/OperationsController.php index 29007f4662..41413fa652 100644 --- a/libraries/classes/Controllers/Table/OperationsController.php +++ b/libraries/classes/Controllers/Table/OperationsController.php @@ -55,7 +55,6 @@ class OperationsController extends AbstractController $GLOBALS['reread_info'] ??= null; $GLOBALS['tbl_is_view'] ??= null; $GLOBALS['tbl_storage_engine'] ??= null; - $GLOBALS['show_comment'] ??= null; $GLOBALS['tbl_collation'] ??= null; $GLOBALS['table_info_num_rows'] ??= null; $GLOBALS['row_format'] ??= null; @@ -110,11 +109,11 @@ class OperationsController extends AbstractController if ($pmaTable->isView()) { $GLOBALS['tbl_is_view'] = true; $GLOBALS['tbl_storage_engine'] = __('View'); - $GLOBALS['show_comment'] = null; + $showComment = ''; } else { $GLOBALS['tbl_is_view'] = false; $GLOBALS['tbl_storage_engine'] = $pmaTable->getStorageEngine(); - $GLOBALS['show_comment'] = $pmaTable->getComment(); + $showComment = $pmaTable->getComment(); } $GLOBALS['tbl_collation'] = $pmaTable->getCollation(); @@ -323,11 +322,11 @@ class OperationsController extends AbstractController if ($pmaTable->isView()) { $GLOBALS['tbl_is_view'] = true; $GLOBALS['tbl_storage_engine'] = __('View'); - $GLOBALS['show_comment'] = null; + $showComment = ''; } else { $GLOBALS['tbl_is_view'] = false; $GLOBALS['tbl_storage_engine'] = $pmaTable->getStorageEngine(); - $GLOBALS['show_comment'] = $pmaTable->getComment(); + $showComment = $pmaTable->getComment(); } $GLOBALS['tbl_collation'] = $pmaTable->getCollation(); @@ -436,17 +435,17 @@ class OperationsController extends AbstractController } $GLOBALS['comment'] = ''; - if (mb_strstr((string) $GLOBALS['show_comment'], '; InnoDB free') === false) { - if (mb_strstr((string) $GLOBALS['show_comment'], 'InnoDB free') === false) { + if (mb_strstr($showComment, '; InnoDB free') === false) { + if (mb_strstr($showComment, 'InnoDB free') === false) { // only user entered comment - $GLOBALS['comment'] = (string) $GLOBALS['show_comment']; + $GLOBALS['comment'] = $showComment; } else { // here we have just InnoDB generated part $GLOBALS['comment'] = ''; } } else { // remove InnoDB comment from end, just the minimal part (*? is non greedy) - $GLOBALS['comment'] = preg_replace('@; InnoDB free:.*?$@', '', (string) $GLOBALS['show_comment']); + $GLOBALS['comment'] = preg_replace('@; InnoDB free:.*?$@', '', $showComment); } $storageEngines = StorageEngine::getArray(); diff --git a/psalm-baseline.xml b/psalm-baseline.xml index ecbed742f6..2cd407e172 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3553,7 +3553,6 @@ - @@ -3588,7 +3587,6 @@ - From dc28c432a144799fd7d6070e76388dd706a3d781 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 27 May 2023 12:28:43 +0100 Subject: [PATCH 02/11] $GLOBALS['row_format'] Signed-off-by: Kamil Tekiela --- .../classes/Controllers/Table/OperationsController.php | 7 +------ psalm-baseline.xml | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/libraries/classes/Controllers/Table/OperationsController.php b/libraries/classes/Controllers/Table/OperationsController.php index 41413fa652..ee013c436d 100644 --- a/libraries/classes/Controllers/Table/OperationsController.php +++ b/libraries/classes/Controllers/Table/OperationsController.php @@ -57,7 +57,6 @@ class OperationsController extends AbstractController $GLOBALS['tbl_storage_engine'] ??= null; $GLOBALS['tbl_collation'] ??= null; $GLOBALS['table_info_num_rows'] ??= null; - $GLOBALS['row_format'] ??= null; $GLOBALS['auto_increment'] ??= null; $GLOBALS['create_options'] ??= null; $GLOBALS['table_alters'] ??= null; @@ -118,7 +117,6 @@ class OperationsController extends AbstractController $GLOBALS['tbl_collation'] = $pmaTable->getCollation(); $GLOBALS['table_info_num_rows'] = $pmaTable->getNumRows(); - $GLOBALS['row_format'] = $pmaTable->getRowFormat(); $GLOBALS['auto_increment'] = $pmaTable->getAutoIncrement(); $GLOBALS['create_options'] = $pmaTable->getCreateOptions(); @@ -229,15 +227,13 @@ class OperationsController extends AbstractController $GLOBALS['new_tbl_storage_engine'] = ''; } - $GLOBALS['row_format'] = $GLOBALS['create_options']['row_format'] ?? $pmaTable->getRowFormat(); - $GLOBALS['table_alters'] = $this->operations->getTableAltersArray( $pmaTable, $GLOBALS['create_options']['pack_keys'], (empty($GLOBALS['create_options']['checksum']) ? '0' : '1'), ($GLOBALS['create_options']['page_checksum'] ?? ''), (empty($GLOBALS['create_options']['delay_key_write']) ? '0' : '1'), - $GLOBALS['row_format'], + $GLOBALS['create_options']['row_format'] ?? $pmaTable->getRowFormat(), $GLOBALS['new_tbl_storage_engine'], (isset($GLOBALS['create_options']['transactional']) && $GLOBALS['create_options']['transactional'] == '0' ? '0' : '1'), @@ -331,7 +327,6 @@ class OperationsController extends AbstractController $GLOBALS['tbl_collation'] = $pmaTable->getCollation(); $GLOBALS['table_info_num_rows'] = $pmaTable->getNumRows(); - $GLOBALS['row_format'] = $pmaTable->getRowFormat(); $GLOBALS['auto_increment'] = $pmaTable->getAutoIncrement(); $GLOBALS['create_options'] = $pmaTable->getCreateOptions(); } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 2cd407e172..f63d52ff2e 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3552,7 +3552,6 @@ - @@ -3586,7 +3585,6 @@ - From b481240bb601aa4fcff8da56d0dfcfeb53341e3f Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 27 May 2023 12:31:05 +0100 Subject: [PATCH 03/11] $GLOBALS['create_options'] Signed-off-by: Kamil Tekiela --- .../Table/OperationsController.php | 43 +++++++++---------- psalm-baseline.xml | 2 - 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/libraries/classes/Controllers/Table/OperationsController.php b/libraries/classes/Controllers/Table/OperationsController.php index ee013c436d..fdc280a2ac 100644 --- a/libraries/classes/Controllers/Table/OperationsController.php +++ b/libraries/classes/Controllers/Table/OperationsController.php @@ -58,7 +58,6 @@ class OperationsController extends AbstractController $GLOBALS['tbl_collation'] ??= null; $GLOBALS['table_info_num_rows'] ??= null; $GLOBALS['auto_increment'] ??= null; - $GLOBALS['create_options'] ??= null; $GLOBALS['table_alters'] ??= null; $GLOBALS['warning_messages'] ??= null; $GLOBALS['reload'] ??= null; @@ -118,19 +117,19 @@ class OperationsController extends AbstractController $GLOBALS['tbl_collation'] = $pmaTable->getCollation(); $GLOBALS['table_info_num_rows'] = $pmaTable->getNumRows(); $GLOBALS['auto_increment'] = $pmaTable->getAutoIncrement(); - $GLOBALS['create_options'] = $pmaTable->getCreateOptions(); + $createOptions = $pmaTable->getCreateOptions(); // set initial value of these variables, based on the current table engine if ($pmaTable->isEngine('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) - // ($create_options['transactional'] may have been set by Table class, - // from the $create_options) - $GLOBALS['create_options']['transactional'] = ($GLOBALS['create_options']['transactional'] ?? '') == '0' + // ($createOptions['transactional'] may have been set by Table class, + // from the $createOptions) + $createOptions['transactional'] = ($createOptions['transactional'] ?? '') == '0' ? '0' : '1'; - $GLOBALS['create_options']['page_checksum'] ??= ''; + $createOptions['page_checksum'] ??= ''; } $pmaTable = $this->dbi->getTable($GLOBALS['db'], $GLOBALS['table']); @@ -219,9 +218,9 @@ class OperationsController extends AbstractController $GLOBALS['new_tbl_storage_engine'] = mb_strtoupper($newTableStorageEngine); if ($pmaTable->isEngine('ARIA')) { - $GLOBALS['create_options']['transactional'] = ($GLOBALS['create_options']['transactional'] ?? '') + $createOptions['transactional'] = ($createOptions['transactional'] ?? '') == '0' ? '0' : '1'; - $GLOBALS['create_options']['page_checksum'] ??= ''; + $createOptions['page_checksum'] ??= ''; } } else { $GLOBALS['new_tbl_storage_engine'] = ''; @@ -229,14 +228,14 @@ class OperationsController extends AbstractController $GLOBALS['table_alters'] = $this->operations->getTableAltersArray( $pmaTable, - $GLOBALS['create_options']['pack_keys'], - (empty($GLOBALS['create_options']['checksum']) ? '0' : '1'), - ($GLOBALS['create_options']['page_checksum'] ?? ''), - (empty($GLOBALS['create_options']['delay_key_write']) ? '0' : '1'), - $GLOBALS['create_options']['row_format'] ?? $pmaTable->getRowFormat(), + $createOptions['pack_keys'], + (empty($createOptions['checksum']) ? '0' : '1'), + ($createOptions['page_checksum'] ?? ''), + (empty($createOptions['delay_key_write']) ? '0' : '1'), + $createOptions['row_format'] ?? $pmaTable->getRowFormat(), $GLOBALS['new_tbl_storage_engine'], - (isset($GLOBALS['create_options']['transactional']) - && $GLOBALS['create_options']['transactional'] == '0' ? '0' : '1'), + (isset($createOptions['transactional']) + && $createOptions['transactional'] == '0' ? '0' : '1'), $GLOBALS['tbl_collation'], ); @@ -328,7 +327,7 @@ class OperationsController extends AbstractController $GLOBALS['tbl_collation'] = $pmaTable->getCollation(); $GLOBALS['table_info_num_rows'] = $pmaTable->getNumRows(); $GLOBALS['auto_increment'] = $pmaTable->getAutoIncrement(); - $GLOBALS['create_options'] = $pmaTable->getCreateOptions(); + $createOptions = $pmaTable->getCreateOptions(); } unset($GLOBALS['reread_info']); @@ -448,7 +447,7 @@ class OperationsController extends AbstractController $charsets = Charsets::getCharsets($this->dbi, $GLOBALS['cfg']['Server']['DisableIS']); $collations = Charsets::getCollations($this->dbi, $GLOBALS['cfg']['Server']['DisableIS']); - $hasPackKeys = isset($GLOBALS['create_options']['pack_keys']) + $hasPackKeys = isset($createOptions['pack_keys']) && $pmaTable->isEngine(['MYISAM', 'ARIA', 'ISAM']); $hasChecksumAndDelayKeyWrite = $pmaTable->isEngine(['MYISAM', 'ARIA']); $hasTransactionalAndPageChecksum = $pmaTable->isEngine('ARIA'); @@ -500,13 +499,13 @@ class OperationsController extends AbstractController 'has_auto_increment' => $hasAutoIncrement, 'auto_increment' => $GLOBALS['auto_increment'], 'has_pack_keys' => $hasPackKeys, - 'pack_keys' => $GLOBALS['create_options']['pack_keys'] ?? '', + 'pack_keys' => $createOptions['pack_keys'] ?? '', 'has_transactional_and_page_checksum' => $hasTransactionalAndPageChecksum, 'has_checksum_and_delay_key_write' => $hasChecksumAndDelayKeyWrite, - 'delay_key_write' => empty($GLOBALS['create_options']['delay_key_write']) ? '0' : '1', - 'transactional' => ($GLOBALS['create_options']['transactional'] ?? '') == '0' ? '0' : '1', - 'page_checksum' => $GLOBALS['create_options']['page_checksum'] ?? '', - 'checksum' => empty($GLOBALS['create_options']['checksum']) ? '0' : '1', + 'delay_key_write' => empty($createOptions['delay_key_write']) ? '0' : '1', + 'transactional' => ($createOptions['transactional'] ?? '') == '0' ? '0' : '1', + 'page_checksum' => $createOptions['page_checksum'] ?? '', + 'checksum' => empty($createOptions['checksum']) ? '0' : '1', 'database_list' => $databaseList, 'has_foreign_keys' => $hasForeignKeys, 'has_privileges' => $hasPrivileges, diff --git a/psalm-baseline.xml b/psalm-baseline.xml index f63d52ff2e..ef841b1c99 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3542,7 +3542,6 @@ - @@ -3574,7 +3573,6 @@ - From 08454dcf2e7cd6d2806fc563df7ca9ee9d8a7d0a Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 27 May 2023 12:33:29 +0100 Subject: [PATCH 04/11] $GLOBALS['table_alters'] Signed-off-by: Kamil Tekiela --- .../classes/Controllers/Table/OperationsController.php | 9 +++------ psalm-baseline.xml | 4 +--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/libraries/classes/Controllers/Table/OperationsController.php b/libraries/classes/Controllers/Table/OperationsController.php index fdc280a2ac..2fc29cb02a 100644 --- a/libraries/classes/Controllers/Table/OperationsController.php +++ b/libraries/classes/Controllers/Table/OperationsController.php @@ -58,7 +58,6 @@ class OperationsController extends AbstractController $GLOBALS['tbl_collation'] ??= null; $GLOBALS['table_info_num_rows'] ??= null; $GLOBALS['auto_increment'] ??= null; - $GLOBALS['table_alters'] ??= null; $GLOBALS['warning_messages'] ??= null; $GLOBALS['reload'] ??= null; $GLOBALS['result'] ??= null; @@ -134,7 +133,6 @@ class OperationsController extends AbstractController $pmaTable = $this->dbi->getTable($GLOBALS['db'], $GLOBALS['table']); $GLOBALS['reread_info'] = false; - $GLOBALS['table_alters'] = []; /** * If the table has to be moved to some other database @@ -226,7 +224,7 @@ class OperationsController extends AbstractController $GLOBALS['new_tbl_storage_engine'] = ''; } - $GLOBALS['table_alters'] = $this->operations->getTableAltersArray( + $tableAlters = $this->operations->getTableAltersArray( $pmaTable, $createOptions['pack_keys'], (empty($createOptions['checksum']) ? '0' : '1'), @@ -239,14 +237,13 @@ class OperationsController extends AbstractController $GLOBALS['tbl_collation'], ); - if ($GLOBALS['table_alters'] !== []) { + if ($tableAlters !== []) { $GLOBALS['sql_query'] = 'ALTER TABLE ' . Util::backquote($GLOBALS['table']); - $GLOBALS['sql_query'] .= "\r\n" . implode("\r\n", $GLOBALS['table_alters']); + $GLOBALS['sql_query'] .= "\r\n" . implode("\r\n", $tableAlters); $GLOBALS['sql_query'] .= ';'; $GLOBALS['result'] = (bool) $this->dbi->query($GLOBALS['sql_query']); $GLOBALS['reread_info'] = true; - unset($GLOBALS['table_alters']); $GLOBALS['warning_messages'] = $this->operations->getWarningMessagesArray(); } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index ef841b1c99..dd3f60b781 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3551,7 +3551,6 @@ - @@ -3563,7 +3562,7 @@ $newMessage - + $tableAlters is_array($partitionNames) ? $partitionNames : [] @@ -3585,7 +3584,6 @@ - From d8e75913c8811b371a5bd70064f8436fe29e9920 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 27 May 2023 12:37:45 +0100 Subject: [PATCH 05/11] $GLOBALS['new_tbl_storage_engine'] Signed-off-by: Kamil Tekiela --- .../classes/Controllers/Table/OperationsController.php | 8 +++----- psalm-baseline.xml | 2 -- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libraries/classes/Controllers/Table/OperationsController.php b/libraries/classes/Controllers/Table/OperationsController.php index 2fc29cb02a..83b2333214 100644 --- a/libraries/classes/Controllers/Table/OperationsController.php +++ b/libraries/classes/Controllers/Table/OperationsController.php @@ -61,7 +61,6 @@ class OperationsController extends AbstractController $GLOBALS['warning_messages'] ??= null; $GLOBALS['reload'] ??= null; $GLOBALS['result'] ??= null; - $GLOBALS['new_tbl_storage_engine'] ??= null; $GLOBALS['message_to_show'] ??= null; $GLOBALS['columns'] ??= null; $GLOBALS['hideOrderTable'] ??= null; @@ -209,19 +208,18 @@ class OperationsController extends AbstractController /** @var mixed $newTableStorageEngine */ $newTableStorageEngine = $request->getParsedBodyParam('new_tbl_storage_engine'); + $newTblStorageEngine = ''; if ( is_string($newTableStorageEngine) && $newTableStorageEngine !== '' && mb_strtoupper($newTableStorageEngine) !== $GLOBALS['tbl_storage_engine'] ) { - $GLOBALS['new_tbl_storage_engine'] = mb_strtoupper($newTableStorageEngine); + $newTblStorageEngine = mb_strtoupper($newTableStorageEngine); if ($pmaTable->isEngine('ARIA')) { $createOptions['transactional'] = ($createOptions['transactional'] ?? '') == '0' ? '0' : '1'; $createOptions['page_checksum'] ??= ''; } - } else { - $GLOBALS['new_tbl_storage_engine'] = ''; } $tableAlters = $this->operations->getTableAltersArray( @@ -231,7 +229,7 @@ class OperationsController extends AbstractController ($createOptions['page_checksum'] ?? ''), (empty($createOptions['delay_key_write']) ? '0' : '1'), $createOptions['row_format'] ?? $pmaTable->getRowFormat(), - $GLOBALS['new_tbl_storage_engine'], + $newTblStorageEngine, (isset($createOptions['transactional']) && $createOptions['transactional'] == '0' ? '0' : '1'), $GLOBALS['tbl_collation'], diff --git a/psalm-baseline.xml b/psalm-baseline.xml index dd3f60b781..1b1979e5ad 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3546,7 +3546,6 @@ - @@ -3576,7 +3575,6 @@ - From c215ed7baa2f91b9d704e2624920b3a99c14d9b9 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 27 May 2023 12:40:21 +0100 Subject: [PATCH 06/11] $GLOBALS['columns'] Signed-off-by: Kamil Tekiela --- libraries/classes/Controllers/Table/OperationsController.php | 5 ++--- psalm-baseline.xml | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/libraries/classes/Controllers/Table/OperationsController.php b/libraries/classes/Controllers/Table/OperationsController.php index 83b2333214..4994af1d5e 100644 --- a/libraries/classes/Controllers/Table/OperationsController.php +++ b/libraries/classes/Controllers/Table/OperationsController.php @@ -62,7 +62,6 @@ class OperationsController extends AbstractController $GLOBALS['reload'] ??= null; $GLOBALS['result'] ??= null; $GLOBALS['message_to_show'] ??= null; - $GLOBALS['columns'] ??= null; $GLOBALS['hideOrderTable'] ??= null; $GLOBALS['indexes'] ??= null; $GLOBALS['notNull'] ??= null; @@ -390,7 +389,7 @@ class OperationsController extends AbstractController $GLOBALS['urlParams']['goto'] = $GLOBALS['urlParams']['back'] = Url::getFromRoute('/table/operations'); - $GLOBALS['columns'] = $this->dbi->getColumns($GLOBALS['db'], $GLOBALS['table']); + $columns = $this->dbi->getColumns($GLOBALS['db'], $GLOBALS['table']); $GLOBALS['hideOrderTable'] = false; // `ALTER TABLE ORDER BY` does not make sense for InnoDB tables that contain @@ -481,7 +480,7 @@ class OperationsController extends AbstractController 'db' => $GLOBALS['db'], 'table' => $GLOBALS['table'], 'url_params' => $GLOBALS['urlParams'], - 'columns' => $GLOBALS['columns'], + 'columns' => $columns, 'hide_order_table' => $GLOBALS['hideOrderTable'], 'table_comment' => $GLOBALS['comment'], 'storage_engine' => $GLOBALS['tbl_storage_engine'], diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 1b1979e5ad..fae26f5dcc 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3540,7 +3540,6 @@ - @@ -3569,7 +3568,6 @@ - From 9a13768bf9b13c6e9c9615074ece1c6fbb34ea17 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 27 May 2023 12:41:21 +0100 Subject: [PATCH 07/11] $GLOBALS['hideOrderTable'] Signed-off-by: Kamil Tekiela --- .../classes/Controllers/Table/OperationsController.php | 9 ++++----- psalm-baseline.xml | 2 -- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libraries/classes/Controllers/Table/OperationsController.php b/libraries/classes/Controllers/Table/OperationsController.php index 4994af1d5e..d587a65607 100644 --- a/libraries/classes/Controllers/Table/OperationsController.php +++ b/libraries/classes/Controllers/Table/OperationsController.php @@ -62,7 +62,6 @@ class OperationsController extends AbstractController $GLOBALS['reload'] ??= null; $GLOBALS['result'] ??= null; $GLOBALS['message_to_show'] ??= null; - $GLOBALS['hideOrderTable'] ??= null; $GLOBALS['indexes'] ??= null; $GLOBALS['notNull'] ??= null; $GLOBALS['comment'] ??= null; @@ -391,7 +390,7 @@ class OperationsController extends AbstractController $columns = $this->dbi->getColumns($GLOBALS['db'], $GLOBALS['table']); - $GLOBALS['hideOrderTable'] = false; + $hideOrderTable = false; // `ALTER TABLE ORDER BY` does not make sense for InnoDB tables that contain // a user-defined clustered index (PRIMARY KEY or NOT NULL UNIQUE index). // InnoDB always orders table rows according to such an index if one is present. @@ -399,7 +398,7 @@ class OperationsController extends AbstractController $GLOBALS['indexes'] = Index::getFromTable($this->dbi, $GLOBALS['table'], $GLOBALS['db']); foreach ($GLOBALS['indexes'] as $name => $idx) { if ($name === 'PRIMARY') { - $GLOBALS['hideOrderTable'] = true; + $hideOrderTable = true; break; } @@ -416,7 +415,7 @@ class OperationsController extends AbstractController } if ($GLOBALS['notNull']) { - $GLOBALS['hideOrderTable'] = true; + $hideOrderTable = true; break; } } @@ -481,7 +480,7 @@ class OperationsController extends AbstractController 'table' => $GLOBALS['table'], 'url_params' => $GLOBALS['urlParams'], 'columns' => $columns, - 'hide_order_table' => $GLOBALS['hideOrderTable'], + 'hide_order_table' => $hideOrderTable, 'table_comment' => $GLOBALS['comment'], 'storage_engine' => $GLOBALS['tbl_storage_engine'], 'storage_engines' => $storageEngines, diff --git a/psalm-baseline.xml b/psalm-baseline.xml index fae26f5dcc..62740abd0f 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3542,7 +3542,6 @@ - @@ -3570,7 +3569,6 @@ - From df1aef483ee5d7e692161c1ba9e517d5ed9b057b Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 27 May 2023 12:42:05 +0100 Subject: [PATCH 08/11] $GLOBALS['indexes'] Signed-off-by: Kamil Tekiela --- libraries/classes/Controllers/Table/OperationsController.php | 5 ++--- psalm-baseline.xml | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/libraries/classes/Controllers/Table/OperationsController.php b/libraries/classes/Controllers/Table/OperationsController.php index d587a65607..e7b16b9215 100644 --- a/libraries/classes/Controllers/Table/OperationsController.php +++ b/libraries/classes/Controllers/Table/OperationsController.php @@ -62,7 +62,6 @@ class OperationsController extends AbstractController $GLOBALS['reload'] ??= null; $GLOBALS['result'] ??= null; $GLOBALS['message_to_show'] ??= null; - $GLOBALS['indexes'] ??= null; $GLOBALS['notNull'] ??= null; $GLOBALS['comment'] ??= null; $GLOBALS['errorUrl'] ??= null; @@ -395,8 +394,8 @@ class OperationsController extends AbstractController // a user-defined clustered index (PRIMARY KEY or NOT NULL UNIQUE index). // InnoDB always orders table rows according to such an index if one is present. if ($GLOBALS['tbl_storage_engine'] === 'INNODB') { - $GLOBALS['indexes'] = Index::getFromTable($this->dbi, $GLOBALS['table'], $GLOBALS['db']); - foreach ($GLOBALS['indexes'] as $name => $idx) { + $indexes = Index::getFromTable($this->dbi, $GLOBALS['table'], $GLOBALS['db']); + foreach ($indexes as $name => $idx) { if ($name === 'PRIMARY') { $hideOrderTable = true; break; diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 62740abd0f..c6e7f8ce6c 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3542,7 +3542,6 @@ - @@ -3569,7 +3568,6 @@ - From 414108520424286c1554d6c1ab61ab6e92581e6b Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 27 May 2023 12:43:18 +0100 Subject: [PATCH 09/11] $GLOBALS['notNull'] Signed-off-by: Kamil Tekiela --- .../classes/Controllers/Table/OperationsController.php | 7 +++---- psalm-baseline.xml | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/libraries/classes/Controllers/Table/OperationsController.php b/libraries/classes/Controllers/Table/OperationsController.php index e7b16b9215..b0ed05045a 100644 --- a/libraries/classes/Controllers/Table/OperationsController.php +++ b/libraries/classes/Controllers/Table/OperationsController.php @@ -62,7 +62,6 @@ class OperationsController extends AbstractController $GLOBALS['reload'] ??= null; $GLOBALS['result'] ??= null; $GLOBALS['message_to_show'] ??= null; - $GLOBALS['notNull'] ??= null; $GLOBALS['comment'] ??= null; $GLOBALS['errorUrl'] ??= null; @@ -405,15 +404,15 @@ class OperationsController extends AbstractController continue; } - $GLOBALS['notNull'] = true; + $notNull = true; foreach ($idx->getColumns() as $column) { if ($column->getNull()) { - $GLOBALS['notNull'] = false; + $notNull = false; break; } } - if ($GLOBALS['notNull']) { + if ($notNull) { $hideOrderTable = true; break; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index c6e7f8ce6c..e8013735cb 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3543,7 +3543,6 @@ - @@ -3569,7 +3568,6 @@ - From 872410ea1be1b0e5c65ab5447f32e06f88910d44 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 27 May 2023 12:45:24 +0100 Subject: [PATCH 10/11] $GLOBALS['comment'] Signed-off-by: Kamil Tekiela --- .../Controllers/Table/OperationsController.php | 12 ++++-------- psalm-baseline.xml | 2 -- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/libraries/classes/Controllers/Table/OperationsController.php b/libraries/classes/Controllers/Table/OperationsController.php index b0ed05045a..5b4ae7a51a 100644 --- a/libraries/classes/Controllers/Table/OperationsController.php +++ b/libraries/classes/Controllers/Table/OperationsController.php @@ -62,7 +62,6 @@ class OperationsController extends AbstractController $GLOBALS['reload'] ??= null; $GLOBALS['result'] ??= null; $GLOBALS['message_to_show'] ??= null; - $GLOBALS['comment'] ??= null; $GLOBALS['errorUrl'] ??= null; $this->checkUserPrivileges->getPrivileges(); @@ -419,18 +418,15 @@ class OperationsController extends AbstractController } } - $GLOBALS['comment'] = ''; + $comment = ''; if (mb_strstr($showComment, '; InnoDB free') === false) { if (mb_strstr($showComment, 'InnoDB free') === false) { // only user entered comment - $GLOBALS['comment'] = $showComment; - } else { - // here we have just InnoDB generated part - $GLOBALS['comment'] = ''; + $comment = $showComment; } } else { // remove InnoDB comment from end, just the minimal part (*? is non greedy) - $GLOBALS['comment'] = preg_replace('@; InnoDB free:.*?$@', '', $showComment); + $comment = preg_replace('@; InnoDB free:.*?$@', '', $showComment); } $storageEngines = StorageEngine::getArray(); @@ -479,7 +475,7 @@ class OperationsController extends AbstractController 'url_params' => $GLOBALS['urlParams'], 'columns' => $columns, 'hide_order_table' => $hideOrderTable, - 'table_comment' => $GLOBALS['comment'], + 'table_comment' => $comment, 'storage_engine' => $GLOBALS['tbl_storage_engine'], 'storage_engines' => $storageEngines, 'charsets' => $charsets, diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e8013735cb..4f18146676 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3540,7 +3540,6 @@ - @@ -3565,7 +3564,6 @@ - From 6dae32cd7a1a26e609f7ecc715ae67649ad1b65b Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 27 May 2023 12:51:30 +0100 Subject: [PATCH 11/11] $GLOBALS['warning_messages'] Signed-off-by: Kamil Tekiela --- .../Controllers/Table/OperationsController.php | 11 ++++------- .../classes/Controllers/View/OperationsController.php | 8 ++++---- psalm-baseline.xml | 8 -------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/libraries/classes/Controllers/Table/OperationsController.php b/libraries/classes/Controllers/Table/OperationsController.php index 5b4ae7a51a..c82511c2d8 100644 --- a/libraries/classes/Controllers/Table/OperationsController.php +++ b/libraries/classes/Controllers/Table/OperationsController.php @@ -58,7 +58,6 @@ class OperationsController extends AbstractController $GLOBALS['tbl_collation'] ??= null; $GLOBALS['table_info_num_rows'] ??= null; $GLOBALS['auto_increment'] ??= null; - $GLOBALS['warning_messages'] ??= null; $GLOBALS['reload'] ??= null; $GLOBALS['result'] ??= null; $GLOBALS['message_to_show'] ??= null; @@ -157,12 +156,12 @@ class OperationsController extends AbstractController return; } + $warningMessages = []; /** * Updates table comment, type and options if required */ if ($request->hasBodyParam('submitoptions')) { $newMessage = ''; - $GLOBALS['warning_messages'] = []; /** @var mixed $newName */ $newName = $request->getParsedBodyParam('new_name'); @@ -237,7 +236,7 @@ class OperationsController extends AbstractController $GLOBALS['sql_query'] .= ';'; $GLOBALS['result'] = (bool) $this->dbi->query($GLOBALS['sql_query']); $GLOBALS['reread_info'] = true; - $GLOBALS['warning_messages'] = $this->operations->getWarningMessagesArray(); + $warningMessages = $this->operations->getWarningMessagesArray(); } /** @var mixed $tableCollationParam */ @@ -350,9 +349,9 @@ class OperationsController extends AbstractController : Message::error($newMessage); } - if (! empty($GLOBALS['warning_messages'])) { + if ($warningMessages !== []) { $newMessage = new Message(); - $newMessage->addMessagesString($GLOBALS['warning_messages']); + $newMessage->addMessagesString($warningMessages); $newMessage->isError(true); if ($this->response->isAjax()) { $this->response->setRequestStatus(false); @@ -366,8 +365,6 @@ class OperationsController extends AbstractController return; } - - unset($GLOBALS['warning_messages']); } if (empty($GLOBALS['sql_query'])) { diff --git a/libraries/classes/Controllers/View/OperationsController.php b/libraries/classes/Controllers/View/OperationsController.php index bc66027173..cadcdd1268 100644 --- a/libraries/classes/Controllers/View/OperationsController.php +++ b/libraries/classes/Controllers/View/OperationsController.php @@ -38,7 +38,6 @@ class OperationsController extends AbstractController $GLOBALS['urlParams'] ??= null; $GLOBALS['reload'] ??= null; $GLOBALS['result'] ??= null; - $GLOBALS['warning_messages'] ??= null; $tableObject = $this->dbi->getTable($GLOBALS['db'], $GLOBALS['table']); $GLOBALS['errorUrl'] ??= null; @@ -58,6 +57,7 @@ class OperationsController extends AbstractController $type = 'success'; $newname = $request->getParsedBodyParam('new_name'); + $warningMessages = []; if ($request->hasBodyParam('submitoptions')) { if (is_string($newname) && $tableObject->rename($newname)) { $message->addText($tableObject->getLastMessage()); @@ -71,7 +71,7 @@ class OperationsController extends AbstractController $GLOBALS['result'] = false; } - $GLOBALS['warning_messages'] = $this->operations->getWarningMessagesArray(); + $warningMessages = $this->operations->getWarningMessagesArray(); } if (isset($GLOBALS['result'])) { @@ -90,8 +90,8 @@ class OperationsController extends AbstractController $type = $GLOBALS['result'] ? 'success' : 'error'; } - if (! empty($GLOBALS['warning_messages'])) { - $message->addMessagesString($GLOBALS['warning_messages']); + if ($warningMessages !== []) { + $message->addMessagesString($warningMessages); $message->isError(true); } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 4f18146676..f9c9ab38a7 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3548,10 +3548,8 @@ - - $newMessage $newMessage @@ -3575,7 +3573,6 @@ - __construct @@ -4396,16 +4393,11 @@ - - - - - $newname