Merge pull request #17859 from kamil-tekiela/more-globals
Fix Replica bugs Fixes #17849 Closes #17856
This commit is contained in:
commit
a229f313ed
@ -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')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1470,6 +1470,26 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Controllers/Server/DatabasesController.php
|
||||
|
||||
-
|
||||
message: "#^Cannot cast mixed to int\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Controllers/Server/ReplicationController.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#10 \\$hostname of method PhpMyAdmin\\\\ReplicationGui\\:\\:handleControlRequest\\(\\) expects string, mixed given\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Controllers/Server/ReplicationController.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#8 \\$username of method PhpMyAdmin\\\\ReplicationGui\\:\\:handleControlRequest\\(\\) expects string, mixed given\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Controllers/Server/ReplicationController.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#9 \\$pmaPassword of method PhpMyAdmin\\\\ReplicationGui\\:\\:handleControlRequest\\(\\) expects string, mixed given\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Controllers/Server/ReplicationController.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Controllers\\\\Server\\\\Status\\\\Processes\\\\KillController\\:\\:__invoke\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -7130,16 +7150,6 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/ReplicationGui.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\ReplicationGui\\:\\:handleControlRequest\\(\\) has parameter \\$sr with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/ReplicationGui.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\ReplicationGui\\:\\:handleRequestForReplicaChangePrimary\\(\\) has parameter \\$sr with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/ReplicationGui.php
|
||||
|
||||
-
|
||||
message: "#^Only numeric types are allowed in \\+, int\\<0, max\\>\\|false given on the left side\\.$#"
|
||||
count: 1
|
||||
|
||||
@ -2802,12 +2802,11 @@
|
||||
</UnusedVariable>
|
||||
</file>
|
||||
<file src="libraries/classes/Controllers/Server/ReplicationController.php">
|
||||
<MixedArgument occurrences="5">
|
||||
<MixedArgument occurrences="4">
|
||||
<code>$replicaInfo['status']</code>
|
||||
<code>$request->getParsedBodyParam('hostname')</code>
|
||||
<code>$request->getParsedBodyParam('pma_pw')</code>
|
||||
<code>$request->getParsedBodyParam('text_port')</code>
|
||||
<code>$request->getParsedBodyParam('username')</code>
|
||||
<code>$request->getParsedBodyParam('hostname', '')</code>
|
||||
<code>$request->getParsedBodyParam('pma_pw', '')</code>
|
||||
<code>$request->getParsedBodyParam('username', '')</code>
|
||||
</MixedArgument>
|
||||
<MixedAssignment occurrences="4">
|
||||
<code>$GLOBALS['errorUrl']</code>
|
||||
@ -12099,20 +12098,10 @@
|
||||
</PossiblyNullArgument>
|
||||
</file>
|
||||
<file src="libraries/classes/ReplicationGui.php">
|
||||
<MixedArgument occurrences="16">
|
||||
<MixedArgument occurrences="6">
|
||||
<code>$database</code>
|
||||
<code>$errorMessage</code>
|
||||
<code>$serverReplicationVariable</code>
|
||||
<code>$sr['hostname']</code>
|
||||
<code>$sr['hostname']</code>
|
||||
<code>$sr['hostname']</code>
|
||||
<code>$sr['hostname']</code>
|
||||
<code>$sr['pma_pw']</code>
|
||||
<code>$sr['pma_pw']</code>
|
||||
<code>$sr['port']</code>
|
||||
<code>$sr['port']</code>
|
||||
<code>$sr['username']</code>
|
||||
<code>$sr['username']</code>
|
||||
<code>$successMessage</code>
|
||||
<code>$val['Type']</code>
|
||||
<code>$val['Type']</code>
|
||||
@ -12151,11 +12140,7 @@
|
||||
<code>$_SESSION['replication']['sr_action_status']</code>
|
||||
<code>$_SESSION['replication']['sr_action_status']</code>
|
||||
</MixedArrayAssignment>
|
||||
<MixedAssignment occurrences="10">
|
||||
<code>$_SESSION['replication']['m_hostname']</code>
|
||||
<code>$_SESSION['replication']['m_password']</code>
|
||||
<code>$_SESSION['replication']['m_port']</code>
|
||||
<code>$_SESSION['replication']['m_username']</code>
|
||||
<MixedAssignment occurrences="6">
|
||||
<code>$database</code>
|
||||
<code>$errorMessage</code>
|
||||
<code>$linkToPrimary</code>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user