From: David Barratt Date: Wed, 23 Jan 2019 22:53:56 +0000 (-0500) Subject: Clone the Title object to prevent mutations. X-Git-Tag: 1.34.0-rc.0~3009^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=dedfe98eaad7015d52001988eeea9c00749e1a30 Clone the Title object to prevent mutations. The Title object that is loaded from master gets reloaded from the replicas and mutates the original object. When pages are moved, the Title no longer exists on master, but still exists on the replicas. Cloning the object allows the item to be loaded from the replicas, without mutating the original Title. Bug: T210739 Change-Id: I9ad973e9a609124749909605f37bc1e1fc549585 --- diff --git a/includes/Title.php b/includes/Title.php index 1bb54df6f9..6ada9b309d 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2708,8 +2708,13 @@ class Title implements LinkTarget, IDBAccessObject { // will get the action where the restriction is the same. This may result // in actions being blocked that shouldn't be. if ( Action::exists( $action ) ) { + // Clone the title to prevent mutations to this object which is done + // by Title::loadFromRow() in WikiPage::loadFromRow(). + $page = WikiPage::factory( clone $this ); + // Creating an action will perform several database queries to ensure that + // the action has not been overridden by the content type. // @todo FIXME: Pass the relevant context into this function. - $action = Action::factory( $action, WikiPage::factory( $this ), RequestContext::getMain() ); + $action = Action::factory( $action, $page, RequestContext::getMain() ); } else { $action = null; }