Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurĂ­cio Meneghini Fauth <mauricio@fauth.dev>2022-11-05 18:31:43 +0300
committerGitHub <noreply@github.com>2022-11-05 18:31:43 +0300
commita229f313ede31d1b081a65c8eccdb06b10c7be8a (patch)
tree7a36b33b492b5f97c01e695cdd596435009f32d5 /libraries
parent56801fa9965f61b3bc53f29ffd2d1d85e886d679 (diff)
parent7ee4c77036365a9b6f234fb15eb6ccd8ad9b06b5 (diff)
Merge pull request #17859 from kamil-tekiela/more-globals
Fix Replica bugs Fixes #17849 Closes #17856
Diffstat (limited to 'libraries')
-rw-r--r--libraries/classes/Controllers/Server/ReplicationController.php10
-rw-r--r--libraries/classes/Replication.php16
-rw-r--r--libraries/classes/ReplicationGui.php43
3 files changed, 37 insertions, 32 deletions
diff --git a/libraries/classes/Controllers/Server/ReplicationController.php b/libraries/classes/Controllers/Server/ReplicationController.php
index 17a816554c..8d210a9ed4 100644
--- a/libraries/classes/Controllers/Server/ReplicationController.php
+++ b/libraries/classes/Controllers/Server/ReplicationController.php
@@ -87,12 +87,10 @@ class ReplicationController extends AbstractController
$request->getParsedBodyParam('sr_replica_skip_error') !== null,
(int) $srSkipErrorsCount,
$srReplicaControlParam,
- [
- 'username' => $GLOBALS['dbi']->escapeString($request->getParsedBodyParam('username')),
- 'pma_pw' => $GLOBALS['dbi']->escapeString($request->getParsedBodyParam('pma_pw')),
- 'hostname' => $GLOBALS['dbi']->escapeString($request->getParsedBodyParam('hostname')),
- 'port' => (int) $GLOBALS['dbi']->escapeString($request->getParsedBodyParam('text_port')),
- ]
+ $request->getParsedBodyParam('username', ''),
+ $request->getParsedBodyParam('pma_pw', ''),
+ $request->getParsedBodyParam('hostname', ''),
+ (int) $request->getParsedBodyParam('text_port')
);
}
diff --git a/libraries/classes/Replication.php b/libraries/classes/Replication.php
index ecbb9539b0..f7972e66ee 100644
--- a/libraries/classes/Replication.php
+++ b/libraries/classes/Replication.php
@@ -78,10 +78,10 @@ class Replication
* @return ResultInterface|false output of CHANGE MASTER mysql command
*/
public function replicaChangePrimary(
- $user,
- $password,
- $host,
- $port,
+ string $user,
+ string $password,
+ string $host,
+ int $port,
array $pos,
bool $stop,
bool $start,
@@ -93,10 +93,10 @@ class Replication
$out = $GLOBALS['dbi']->tryQuery(
'CHANGE MASTER TO ' .
- 'MASTER_HOST=\'' . $host . '\',' .
- 'MASTER_PORT=' . ($port * 1) . ',' .
- 'MASTER_USER=\'' . $user . '\',' .
- 'MASTER_PASSWORD=\'' . $password . '\',' .
+ 'MASTER_HOST=\'' . $GLOBALS['dbi']->escapeString($host) . '\',' .
+ 'MASTER_PORT=' . $port . ',' .
+ 'MASTER_USER=\'' . $GLOBALS['dbi']->escapeString($user) . '\',' .
+ 'MASTER_PASSWORD=\'' . $GLOBALS['dbi']->escapeString($password) . '\',' .
'MASTER_LOG_FILE=\'' . $pos['File'] . '\',' .
'MASTER_LOG_POS=' . $pos['Position'] . ';',
$link
diff --git a/libraries/classes/ReplicationGui.php b/libraries/classes/ReplicationGui.php
index 0174c9da0a..8c72de9e98 100644
--- a/libraries/classes/ReplicationGui.php
+++ b/libraries/classes/ReplicationGui.php
@@ -427,7 +427,10 @@ class ReplicationGui
bool $srReplicaSkipError,
int $srSkipErrorsCount,
?string $srReplicaControlParam,
- array $sr
+ string $username,
+ string $pmaPassword,
+ string $hostname,
+ int $port
): void {
if (! $srTakeAction) {
return;
@@ -445,7 +448,7 @@ class ReplicationGui
. ' $cfg[\'AllowArbitraryServer\'] in phpMyAdmin configuration.'
);
} elseif ($replicaChangePrimary) {
- $result = $this->handleRequestForReplicaChangePrimary($sr);
+ $result = $this->handleRequestForReplicaChangePrimary($username, $pmaPassword, $hostname, $port);
} elseif ($srReplicaServerControl) {
$result = $this->handleRequestForReplicaServerControl($srReplicaAction, $srReplicaControlParam);
$refresh = true;
@@ -493,29 +496,33 @@ class ReplicationGui
unset($refresh);
}
- public function handleRequestForReplicaChangePrimary(array $sr): bool
- {
- $_SESSION['replication']['m_username'] = $sr['username'];
- $_SESSION['replication']['m_password'] = $sr['pma_pw'];
- $_SESSION['replication']['m_hostname'] = $sr['hostname'];
- $_SESSION['replication']['m_port'] = $sr['port'];
+ public function handleRequestForReplicaChangePrimary(
+ string $username,
+ string $pmaPassword,
+ string $hostname,
+ int $port
+ ): bool {
+ $_SESSION['replication']['m_username'] = $username;
+ $_SESSION['replication']['m_password'] = $pmaPassword;
+ $_SESSION['replication']['m_hostname'] = $hostname;
+ $_SESSION['replication']['m_port'] = $port;
$_SESSION['replication']['m_correct'] = '';
$_SESSION['replication']['sr_action_status'] = 'error';
$_SESSION['replication']['sr_action_info'] = __('Unknown error');
// Attempt to connect to the new primary server
$linkToPrimary = $this->replication->connectToPrimary(
- $sr['username'],
- $sr['pma_pw'],
- $sr['hostname'],
- $sr['port']
+ $username,
+ $pmaPassword,
+ $hostname,
+ $port
);
if (! $linkToPrimary) {
$_SESSION['replication']['sr_action_status'] = 'error';
$_SESSION['replication']['sr_action_info'] = sprintf(
__('Unable to connect to primary %s.'),
- htmlspecialchars($sr['hostname'])
+ htmlspecialchars($hostname)
);
} else {
// Read the current primary position
@@ -531,10 +538,10 @@ class ReplicationGui
if (
! $this->replication->replicaChangePrimary(
- $sr['username'],
- $sr['pma_pw'],
- $sr['hostname'],
- $sr['port'],
+ $username,
+ $pmaPassword,
+ $hostname,
+ $port,
$position,
true,
false,
@@ -547,7 +554,7 @@ class ReplicationGui
$_SESSION['replication']['sr_action_status'] = 'success';
$_SESSION['replication']['sr_action_info'] = sprintf(
__('Primary server changed successfully to %s.'),
- htmlspecialchars($sr['hostname'])
+ htmlspecialchars($hostname)
);
}
}