Merge "Added future compat expectException to PHPUnit4And6Compat trait"
[lhc/web/wiklou.git] / includes / Title.php
index 1bb54df..f5904e2 100644 (file)
@@ -1835,7 +1835,7 @@ class Title implements LinkTarget, IDBAccessObject {
         * @endcode
         *
         * @param string $text The subpage name to add to the title
-        * @return Title Subpage title
+        * @return Title|null Subpage title, or null on an error
         * @since 1.20
         */
        public function getSubpage( $text ) {
@@ -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;
                }