@@ -55,23 +55,12 @@ public function __invoke(ServerRequest $request): void
5555 $ GLOBALS ['reread_info ' ] ??= null ;
5656 $ GLOBALS ['tbl_is_view ' ] ??= null ;
5757 $ GLOBALS ['tbl_storage_engine ' ] ??= null ;
58- $ GLOBALS ['show_comment ' ] ??= null ;
5958 $ GLOBALS ['tbl_collation ' ] ??= null ;
6059 $ GLOBALS ['table_info_num_rows ' ] ??= null ;
61- $ GLOBALS ['row_format ' ] ??= null ;
6260 $ GLOBALS ['auto_increment ' ] ??= null ;
63- $ GLOBALS ['create_options ' ] ??= null ;
64- $ GLOBALS ['table_alters ' ] ??= null ;
65- $ GLOBALS ['warning_messages ' ] ??= null ;
6661 $ GLOBALS ['reload ' ] ??= null ;
6762 $ GLOBALS ['result ' ] ??= null ;
68- $ GLOBALS ['new_tbl_storage_engine ' ] ??= null ;
6963 $ GLOBALS ['message_to_show ' ] ??= null ;
70- $ GLOBALS ['columns ' ] ??= null ;
71- $ GLOBALS ['hideOrderTable ' ] ??= null ;
72- $ GLOBALS ['indexes ' ] ??= null ;
73- $ GLOBALS ['notNull ' ] ??= null ;
74- $ GLOBALS ['comment ' ] ??= null ;
7564 $ GLOBALS ['errorUrl ' ] ??= null ;
7665
7766 $ this ->checkUserPrivileges ->getPrivileges ();
@@ -110,35 +99,33 @@ public function __invoke(ServerRequest $request): void
11099 if ($ pmaTable ->isView ()) {
111100 $ GLOBALS ['tbl_is_view ' ] = true ;
112101 $ GLOBALS ['tbl_storage_engine ' ] = __ ('View ' );
113- $ GLOBALS [ ' show_comment ' ] = null ;
102+ $ showComment = '' ;
114103 } else {
115104 $ GLOBALS ['tbl_is_view ' ] = false ;
116105 $ GLOBALS ['tbl_storage_engine ' ] = $ pmaTable ->getStorageEngine ();
117- $ GLOBALS [ ' show_comment ' ] = $ pmaTable ->getComment ();
106+ $ showComment = $ pmaTable ->getComment ();
118107 }
119108
120109 $ GLOBALS ['tbl_collation ' ] = $ pmaTable ->getCollation ();
121110 $ GLOBALS ['table_info_num_rows ' ] = $ pmaTable ->getNumRows ();
122- $ GLOBALS ['row_format ' ] = $ pmaTable ->getRowFormat ();
123111 $ GLOBALS ['auto_increment ' ] = $ pmaTable ->getAutoIncrement ();
124- $ GLOBALS [ ' create_options ' ] = $ pmaTable ->getCreateOptions ();
112+ $ createOptions = $ pmaTable ->getCreateOptions ();
125113
126114 // set initial value of these variables, based on the current table engine
127115 if ($ pmaTable ->isEngine ('ARIA ' )) {
128116 // the value for transactional can be implicit
129117 // (no create option found, in this case it means 1)
130118 // or explicit (option found with a value of 0 or 1)
131- // ($create_options ['transactional'] may have been set by Table class,
132- // from the $create_options )
133- $ GLOBALS [ ' create_options ' ][ ' transactional ' ] = ($ GLOBALS [ ' create_options ' ] ['transactional ' ] ?? '' ) == '0 '
119+ // ($createOptions ['transactional'] may have been set by Table class,
120+ // from the $createOptions )
121+ $ createOptions [ ' transactional ' ] = ($ createOptions ['transactional ' ] ?? '' ) == '0 '
134122 ? '0 '
135123 : '1 ' ;
136- $ GLOBALS [ ' create_options ' ] ['page_checksum ' ] ??= '' ;
124+ $ createOptions ['page_checksum ' ] ??= '' ;
137125 }
138126
139127 $ pmaTable = $ this ->dbi ->getTable ($ GLOBALS ['db ' ], $ GLOBALS ['table ' ]);
140128 $ GLOBALS ['reread_info ' ] = false ;
141- $ GLOBALS ['table_alters ' ] = [];
142129
143130 /**
144131 * If the table has to be moved to some other database
@@ -169,12 +156,12 @@ public function __invoke(ServerRequest $request): void
169156 return ;
170157 }
171158
159+ $ warningMessages = [];
172160 /**
173161 * Updates table comment, type and options if required
174162 */
175163 if ($ request ->hasBodyParam ('submitoptions ' )) {
176164 $ newMessage = '' ;
177- $ GLOBALS ['warning_messages ' ] = [];
178165
179166 /** @var mixed $newName */
180167 $ newName = $ request ->getParsedBodyParam ('new_name ' );
@@ -215,45 +202,41 @@ public function __invoke(ServerRequest $request): void
215202
216203 /** @var mixed $newTableStorageEngine */
217204 $ newTableStorageEngine = $ request ->getParsedBodyParam ('new_tbl_storage_engine ' );
205+ $ newTblStorageEngine = '' ;
218206 if (
219207 is_string ($ newTableStorageEngine ) && $ newTableStorageEngine !== ''
220208 && mb_strtoupper ($ newTableStorageEngine ) !== $ GLOBALS ['tbl_storage_engine ' ]
221209 ) {
222- $ GLOBALS [ ' new_tbl_storage_engine ' ] = mb_strtoupper ($ newTableStorageEngine );
210+ $ newTblStorageEngine = mb_strtoupper ($ newTableStorageEngine );
223211
224212 if ($ pmaTable ->isEngine ('ARIA ' )) {
225- $ GLOBALS [ ' create_options ' ][ ' transactional ' ] = ($ GLOBALS [ ' create_options ' ] ['transactional ' ] ?? '' )
213+ $ createOptions [ ' transactional ' ] = ($ createOptions ['transactional ' ] ?? '' )
226214 == '0 ' ? '0 ' : '1 ' ;
227- $ GLOBALS [ ' create_options ' ] ['page_checksum ' ] ??= '' ;
215+ $ createOptions ['page_checksum ' ] ??= '' ;
228216 }
229- } else {
230- $ GLOBALS ['new_tbl_storage_engine ' ] = '' ;
231217 }
232218
233- $ GLOBALS ['row_format ' ] = $ GLOBALS ['create_options ' ]['row_format ' ] ?? $ pmaTable ->getRowFormat ();
234-
235- $ GLOBALS ['table_alters ' ] = $ this ->operations ->getTableAltersArray (
219+ $ tableAlters = $ this ->operations ->getTableAltersArray (
236220 $ pmaTable ,
237- $ GLOBALS [ ' create_options ' ] ['pack_keys ' ],
238- (empty ($ GLOBALS [ ' create_options ' ] ['checksum ' ]) ? '0 ' : '1 ' ),
239- ($ GLOBALS [ ' create_options ' ] ['page_checksum ' ] ?? '' ),
240- (empty ($ GLOBALS [ ' create_options ' ] ['delay_key_write ' ]) ? '0 ' : '1 ' ),
241- $ GLOBALS ['row_format ' ],
242- $ GLOBALS [ ' new_tbl_storage_engine ' ] ,
243- (isset ($ GLOBALS [ ' create_options ' ] ['transactional ' ])
244- && $ GLOBALS [ ' create_options ' ] ['transactional ' ] == '0 ' ? '0 ' : '1 ' ),
221+ $ createOptions ['pack_keys ' ],
222+ (empty ($ createOptions ['checksum ' ]) ? '0 ' : '1 ' ),
223+ ($ createOptions ['page_checksum ' ] ?? '' ),
224+ (empty ($ createOptions ['delay_key_write ' ]) ? '0 ' : '1 ' ),
225+ $ createOptions ['row_format ' ] ?? $ pmaTable -> getRowFormat () ,
226+ $ newTblStorageEngine ,
227+ (isset ($ createOptions ['transactional ' ])
228+ && $ createOptions ['transactional ' ] == '0 ' ? '0 ' : '1 ' ),
245229 $ GLOBALS ['tbl_collation ' ],
246230 );
247231
248- if ($ GLOBALS [ ' table_alters ' ] !== []) {
232+ if ($ tableAlters !== []) {
249233 $ GLOBALS ['sql_query ' ] = 'ALTER TABLE '
250234 . Util ::backquote ($ GLOBALS ['table ' ]);
251- $ GLOBALS ['sql_query ' ] .= "\r\n" . implode ("\r\n" , $ GLOBALS [ ' table_alters ' ] );
235+ $ GLOBALS ['sql_query ' ] .= "\r\n" . implode ("\r\n" , $ tableAlters );
252236 $ GLOBALS ['sql_query ' ] .= '; ' ;
253237 $ GLOBALS ['result ' ] = (bool ) $ this ->dbi ->query ($ GLOBALS ['sql_query ' ]);
254238 $ GLOBALS ['reread_info ' ] = true ;
255- unset($ GLOBALS ['table_alters ' ]);
256- $ GLOBALS ['warning_messages ' ] = $ this ->operations ->getWarningMessagesArray ();
239+ $ warningMessages = $ this ->operations ->getWarningMessagesArray ();
257240 }
258241
259242 /** @var mixed $tableCollationParam */
@@ -323,18 +306,17 @@ public function __invoke(ServerRequest $request): void
323306 if ($ pmaTable ->isView ()) {
324307 $ GLOBALS ['tbl_is_view ' ] = true ;
325308 $ GLOBALS ['tbl_storage_engine ' ] = __ ('View ' );
326- $ GLOBALS [ ' show_comment ' ] = null ;
309+ $ showComment = '' ;
327310 } else {
328311 $ GLOBALS ['tbl_is_view ' ] = false ;
329312 $ GLOBALS ['tbl_storage_engine ' ] = $ pmaTable ->getStorageEngine ();
330- $ GLOBALS [ ' show_comment ' ] = $ pmaTable ->getComment ();
313+ $ showComment = $ pmaTable ->getComment ();
331314 }
332315
333316 $ GLOBALS ['tbl_collation ' ] = $ pmaTable ->getCollation ();
334317 $ GLOBALS ['table_info_num_rows ' ] = $ pmaTable ->getNumRows ();
335- $ GLOBALS ['row_format ' ] = $ pmaTable ->getRowFormat ();
336318 $ GLOBALS ['auto_increment ' ] = $ pmaTable ->getAutoIncrement ();
337- $ GLOBALS [ ' create_options ' ] = $ pmaTable ->getCreateOptions ();
319+ $ createOptions = $ pmaTable ->getCreateOptions ();
338320 }
339321
340322 unset($ GLOBALS ['reread_info ' ]);
@@ -367,9 +349,9 @@ public function __invoke(ServerRequest $request): void
367349 : Message ::error ($ newMessage );
368350 }
369351
370- if (! empty ( $ GLOBALS [ ' warning_messages ' ]) ) {
352+ if ($ warningMessages !== [] ) {
371353 $ newMessage = new Message ();
372- $ newMessage ->addMessagesString ($ GLOBALS [ ' warning_messages ' ] );
354+ $ newMessage ->addMessagesString ($ warningMessages );
373355 $ newMessage ->isError (true );
374356 if ($ this ->response ->isAjax ()) {
375357 $ this ->response ->setRequestStatus (false );
@@ -383,8 +365,6 @@ public function __invoke(ServerRequest $request): void
383365
384366 return ;
385367 }
386-
387- unset($ GLOBALS ['warning_messages ' ]);
388368 }
389369
390370 if (empty ($ GLOBALS ['sql_query ' ])) {
@@ -402,59 +382,56 @@ public function __invoke(ServerRequest $request): void
402382
403383 $ GLOBALS ['urlParams ' ]['goto ' ] = $ GLOBALS ['urlParams ' ]['back ' ] = Url ::getFromRoute ('/table/operations ' );
404384
405- $ GLOBALS [ ' columns ' ] = $ this ->dbi ->getColumns ($ GLOBALS ['db ' ], $ GLOBALS ['table ' ]);
385+ $ columns = $ this ->dbi ->getColumns ($ GLOBALS ['db ' ], $ GLOBALS ['table ' ]);
406386
407- $ GLOBALS [ ' hideOrderTable ' ] = false ;
387+ $ hideOrderTable = false ;
408388 // `ALTER TABLE ORDER BY` does not make sense for InnoDB tables that contain
409389 // a user-defined clustered index (PRIMARY KEY or NOT NULL UNIQUE index).
410390 // InnoDB always orders table rows according to such an index if one is present.
411391 if ($ GLOBALS ['tbl_storage_engine ' ] === 'INNODB ' ) {
412- $ GLOBALS [ ' indexes ' ] = Index ::getFromTable ($ this ->dbi , $ GLOBALS ['table ' ], $ GLOBALS ['db ' ]);
413- foreach ($ GLOBALS [ ' indexes ' ] as $ name => $ idx ) {
392+ $ indexes = Index ::getFromTable ($ this ->dbi , $ GLOBALS ['table ' ], $ GLOBALS ['db ' ]);
393+ foreach ($ indexes as $ name => $ idx ) {
414394 if ($ name === 'PRIMARY ' ) {
415- $ GLOBALS [ ' hideOrderTable ' ] = true ;
395+ $ hideOrderTable = true ;
416396 break ;
417397 }
418398
419399 if ($ idx ->getNonUnique ()) {
420400 continue ;
421401 }
422402
423- $ GLOBALS [ ' notNull ' ] = true ;
403+ $ notNull = true ;
424404 foreach ($ idx ->getColumns () as $ column ) {
425405 if ($ column ->getNull ()) {
426- $ GLOBALS [ ' notNull ' ] = false ;
406+ $ notNull = false ;
427407 break ;
428408 }
429409 }
430410
431- if ($ GLOBALS [ ' notNull ' ] ) {
432- $ GLOBALS [ ' hideOrderTable ' ] = true ;
411+ if ($ notNull ) {
412+ $ hideOrderTable = true ;
433413 break ;
434414 }
435415 }
436416 }
437417
438- $ GLOBALS [ ' comment ' ] = '' ;
439- if (mb_strstr (( string ) $ GLOBALS [ ' show_comment ' ] , '; InnoDB free ' ) === false ) {
440- if (mb_strstr (( string ) $ GLOBALS [ ' show_comment ' ] , 'InnoDB free ' ) === false ) {
418+ $ comment = '' ;
419+ if (mb_strstr ($ showComment , '; InnoDB free ' ) === false ) {
420+ if (mb_strstr ($ showComment , 'InnoDB free ' ) === false ) {
441421 // only user entered comment
442- $ GLOBALS ['comment ' ] = (string ) $ GLOBALS ['show_comment ' ];
443- } else {
444- // here we have just InnoDB generated part
445- $ GLOBALS ['comment ' ] = '' ;
422+ $ comment = $ showComment ;
446423 }
447424 } else {
448425 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
449- $ GLOBALS [ ' comment ' ] = preg_replace ('@; InnoDB free:.*?$@ ' , '' , ( string ) $ GLOBALS [ ' show_comment ' ] );
426+ $ comment = preg_replace ('@; InnoDB free:.*?$@ ' , '' , $ showComment );
450427 }
451428
452429 $ storageEngines = StorageEngine ::getArray ();
453430
454431 $ charsets = Charsets ::getCharsets ($ this ->dbi , $ GLOBALS ['cfg ' ]['Server ' ]['DisableIS ' ]);
455432 $ collations = Charsets ::getCollations ($ this ->dbi , $ GLOBALS ['cfg ' ]['Server ' ]['DisableIS ' ]);
456433
457- $ hasPackKeys = isset ($ GLOBALS [ ' create_options ' ] ['pack_keys ' ])
434+ $ hasPackKeys = isset ($ createOptions ['pack_keys ' ])
458435 && $ pmaTable ->isEngine (['MYISAM ' , 'ARIA ' , 'ISAM ' ]);
459436 $ hasChecksumAndDelayKeyWrite = $ pmaTable ->isEngine (['MYISAM ' , 'ARIA ' ]);
460437 $ hasTransactionalAndPageChecksum = $ pmaTable ->isEngine ('ARIA ' );
@@ -493,9 +470,9 @@ public function __invoke(ServerRequest $request): void
493470 'db ' => $ GLOBALS ['db ' ],
494471 'table ' => $ GLOBALS ['table ' ],
495472 'url_params ' => $ GLOBALS ['urlParams ' ],
496- 'columns ' => $ GLOBALS [ ' columns ' ] ,
497- 'hide_order_table ' => $ GLOBALS [ ' hideOrderTable ' ] ,
498- 'table_comment ' => $ GLOBALS [ ' comment ' ] ,
473+ 'columns ' => $ columns ,
474+ 'hide_order_table ' => $ hideOrderTable ,
475+ 'table_comment ' => $ comment ,
499476 'storage_engine ' => $ GLOBALS ['tbl_storage_engine ' ],
500477 'storage_engines ' => $ storageEngines ,
501478 'charsets ' => $ charsets ,
@@ -506,13 +483,13 @@ public function __invoke(ServerRequest $request): void
506483 'has_auto_increment ' => $ hasAutoIncrement ,
507484 'auto_increment ' => $ GLOBALS ['auto_increment ' ],
508485 'has_pack_keys ' => $ hasPackKeys ,
509- 'pack_keys ' => $ GLOBALS [ ' create_options ' ] ['pack_keys ' ] ?? '' ,
486+ 'pack_keys ' => $ createOptions ['pack_keys ' ] ?? '' ,
510487 'has_transactional_and_page_checksum ' => $ hasTransactionalAndPageChecksum ,
511488 'has_checksum_and_delay_key_write ' => $ hasChecksumAndDelayKeyWrite ,
512- 'delay_key_write ' => empty ($ GLOBALS [ ' create_options ' ] ['delay_key_write ' ]) ? '0 ' : '1 ' ,
513- 'transactional ' => ($ GLOBALS [ ' create_options ' ] ['transactional ' ] ?? '' ) == '0 ' ? '0 ' : '1 ' ,
514- 'page_checksum ' => $ GLOBALS [ ' create_options ' ] ['page_checksum ' ] ?? '' ,
515- 'checksum ' => empty ($ GLOBALS [ ' create_options ' ] ['checksum ' ]) ? '0 ' : '1 ' ,
489+ 'delay_key_write ' => empty ($ createOptions ['delay_key_write ' ]) ? '0 ' : '1 ' ,
490+ 'transactional ' => ($ createOptions ['transactional ' ] ?? '' ) == '0 ' ? '0 ' : '1 ' ,
491+ 'page_checksum ' => $ createOptions ['page_checksum ' ] ?? '' ,
492+ 'checksum ' => empty ($ createOptions ['checksum ' ]) ? '0 ' : '1 ' ,
516493 'database_list ' => $ databaseList ,
517494 'has_foreign_keys ' => $ hasForeignKeys ,
518495 'has_privileges ' => $ hasPrivileges ,
0 commit comments