Fix #16863 - replication issues when setting up a replica

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2021-04-27 23:57:02 +02:00
parent 34f8295b94
commit d3f7411f76
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889
2 changed files with 12 additions and 9 deletions

View File

@ -45,7 +45,7 @@ class Replication
*
* @return mixed|int output of DatabaseInterface::tryQuery
*/
public function slaveControl(string $action, ?string $control, $link = null)
public function slaveControl(string $action, ?string $control, int $link)
{
global $dbi;
@ -73,7 +73,7 @@ class Replication
* array should contain fields File and Position
* @param bool $stop shall we stop slave?
* @param bool $start shall we start slave?
* @param mixed $link mysql link
* @param int $link mysql link
*
* @return string output of CHANGE MASTER mysql command
*/
@ -83,9 +83,9 @@ class Replication
$host,
$port,
array $pos,
$stop = true,
$start = true,
$link = null
bool $stop,
bool $start,
int $link
) {
global $dbi;
@ -146,12 +146,14 @@ class Replication
/**
* Fetches position and file of current binary log on master
*
* @param mixed $link mysql link
* @param int $link mysql link
*
* @return array an array containing File and Position in MySQL replication
* on master server, useful for slaveChangeMaster()
*
* @phpstan-return array{'File'?: string, 'Position'?: string}
*/
public function slaveBinLogMaster($link = null)
public function slaveBinLogMaster(int $link): array
{
global $dbi;

View File

@ -538,7 +538,7 @@ class ReplicationGui
);
} else {
// Read the current master position
$position = $this->replication->slaveBinLogMaster($link_to_master);
$position = $this->replication->slaveBinLogMaster(DatabaseInterface::CONNECT_AUXILIARY);
if (empty($position)) {
$_SESSION['replication']['sr_action_status'] = 'error';
@ -557,7 +557,8 @@ class ReplicationGui
$sr['port'],
$position,
true,
false
false,
DatabaseInterface::CONNECT_USER
)
) {
$_SESSION['replication']['sr_action_status'] = 'error';