1212use PhpMyAdmin \Dbal \DatabaseInterface ;
1313use PhpMyAdmin \Message ;
1414use PhpMyAdmin \Query \Utilities ;
15- use PhpMyAdmin \ResponseRenderer ;
1615use PhpMyAdmin \Template ;
1716use PhpMyAdmin \Url ;
1817use PhpMyAdmin \UrlParams ;
@@ -425,27 +424,21 @@ public function handleControlRequest(
425424 string $ pmaPassword ,
426425 string $ hostname ,
427426 int $ port ,
428- ): void {
427+ ): Message | null {
429428 if (! $ srTakeAction ) {
430- return ;
429+ return null ;
431430 }
432431
433- $ refresh = false ;
434- $ result = false ;
435- $ messageSuccess = '' ;
436- $ messageError = '' ;
437-
438432 if ($ replicaChangePrimary && ! Config::getInstance ()->settings ['AllowArbitraryServer ' ]) {
439433 $ _SESSION ['replication ' ]['sr_action_status ' ] = 'error ' ;
440434 $ _SESSION ['replication ' ]['sr_action_info ' ] = __ (
441435 'Connection to server is disabled, please enable '
442436 . ' $cfg[ \'AllowArbitraryServer \'] in phpMyAdmin configuration. ' ,
443437 );
444438 } elseif ($ replicaChangePrimary ) {
445- $ result = $ this ->handleRequestForReplicaChangePrimary ($ username , $ pmaPassword , $ hostname , $ port );
439+ $ this ->handleRequestForReplicaChangePrimary ($ username , $ pmaPassword , $ hostname , $ port );
446440 } elseif ($ srReplicaServerControl ) {
447441 $ result = $ this ->handleRequestForReplicaServerControl ($ srReplicaAction , $ srReplicaControlParam );
448- $ refresh = true ;
449442
450443 switch ($ srReplicaAction ) {
451444 case 'start ' :
@@ -465,28 +458,13 @@ public function handleControlRequest(
465458 $ messageError = __ ('Error. ' );
466459 break ;
467460 }
468- } elseif ($ srReplicaSkipError ) {
469- $ result = $ this ->handleRequestForReplicaSkipError ($ srSkipErrorsCount );
470- }
471461
472- if ($ refresh ) {
473- $ response = ResponseRenderer::getInstance ();
474- if ($ response ->isAjax ()) {
475- $ response ->setRequestStatus ($ result );
476- $ response ->addJSON (
477- 'message ' ,
478- $ result
479- ? Message::success ($ messageSuccess )
480- : Message::error ($ messageError ),
481- );
482- } else {
483- $ response ->redirect (
484- './index.php?route=/server/replication ' . Url::getCommonRaw (UrlParams::$ params , '& ' ),
485- );
486- }
462+ return $ result ? Message::success ($ messageSuccess ) : Message::error ($ messageError );
463+ } elseif ($ srReplicaSkipError ) {
464+ $ this ->handleRequestForReplicaSkipError ($ srSkipErrorsCount );
487465 }
488466
489- unset( $ refresh ) ;
467+ return null ;
490468 }
491469
492470 public function handleRequestForReplicaChangePrimary (
0 commit comments