From eae891924ca5e05a53fccd16589d7aa4e09c5571 Mon Sep 17 00:00:00 2001 From: CosmicAlpha Date: Tue, 5 Nov 2024 11:38:33 -0700 Subject: [PATCH] RemoteWikiFactory: fix overriding assignment += wont override if it is already set so we either use direct assignment or array_merge depending on how many keys we are setting --- includes/Services/RemoteWikiFactory.php | 35 +++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/includes/Services/RemoteWikiFactory.php b/includes/Services/RemoteWikiFactory.php index f5acb20ff6..98e257d1a4 100644 --- a/includes/Services/RemoteWikiFactory.php +++ b/includes/Services/RemoteWikiFactory.php @@ -166,10 +166,9 @@ public function markInactive(): void { $this->trackChange( 'inactive', 0, 1 ); $this->inactive = true; $this->inactiveTimestamp = $this->dbr->timestamp(); - $this->newRows += [ - 'wiki_inactive' => 1, - 'wiki_inactive_timestamp' => $this->inactiveTimestamp, - ]; + + $this->newRows['wiki_inactive'] = 1; + $this->newRows['wiki_inactive_timestamp'] = $this->inactiveTimestamp; } public function markActive(): void { @@ -179,12 +178,13 @@ public function markActive(): void { $this->closed = false; $this->closedTimestamp = null; $this->inactiveTimestamp = null; - $this->newRows += [ + + $this->newRows = array_merge( $this->newRows, [ 'wiki_closed' => 0, 'wiki_closed_timestamp' => null, 'wiki_inactive' => 0, 'wiki_inactive_timestamp' => null, - ]; + ] ); } public function getInactiveTimestamp(): ?string { @@ -229,9 +229,9 @@ public function isPrivate(): bool { public function markPrivate(): void { $this->trackChange( 'private', 0, 1 ); + $this->hooks[] = 'CreateWikiStatePrivate'; $this->private = true; $this->newRows['wiki_private'] = 1; - $this->hooks[] = 'CreateWikiStatePrivate'; $this->jobQueueGroupFactory->makeJobQueueGroup( $this->dbname )->push( new JobSpecification( @@ -243,9 +243,9 @@ public function markPrivate(): void { public function markPublic(): void { $this->trackChange( 'public', 0, 1 ); + $this->hooks[] = 'CreateWikiStatePublic'; $this->private = false; $this->newRows['wiki_private'] = 0; - $this->hooks[] = 'CreateWikiStatePublic'; $this->jobQueueGroupFactory->makeJobQueueGroup( $this->dbname )->push( new JobSpecification( @@ -261,17 +261,18 @@ public function isClosed(): bool { public function markClosed(): void { $this->trackChange( 'closed', 0, 1 ); + $this->hooks[] = 'CreateWikiStateClosed'; $this->closed = true; $this->inactive = false; $this->closedTimestamp = $this->dbr->timestamp(); $this->inactiveTimestamp = null; - $this->newRows += [ + + $this->newRows = array_merge( $this->newRows, [ 'wiki_closed' => 1, 'wiki_closed_timestamp' => $this->closedTimestamp, 'wiki_inactive' => 0, 'wiki_inactive_timestamp' => null, - ]; - $this->hooks[] = 'CreateWikiStateClosed'; + ] ); } public function getClosedTimestamp(): ?string { @@ -291,14 +292,15 @@ public function delete(): void { $this->deletedTimestamp = $this->dbr->timestamp(); $this->closedTimestamp = null; $this->inactiveTimestamp = null; - $this->newRows += [ + + $this->newRows = array_merge( $this->newRows, [ 'wiki_deleted' => 1, 'wiki_deleted_timestamp' => $this->deletedTimestamp, 'wiki_closed' => 0, 'wiki_closed_timestamp' => null, 'wiki_inactive' => 0, 'wiki_inactive_timestamp' => null, - ]; + ] ); } public function undelete(): void { @@ -306,10 +308,9 @@ public function undelete(): void { $this->log = 'undelete'; $this->deleted = false; $this->deletedTimestamp = null; - $this->newRows += [ - 'wiki_deleted' => 0, - 'wiki_deleted_timestamp' => null, - ]; + + $this->newRows['wiki_deleted'] = 0; + $this->newRows['wiki_deleted_timestamp'] = null; } public function getDeletedTimestamp(): ?string {