Merge "Update article count when pages are moved"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 4 Nov 2014 06:25:07 +0000 (06:25 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 4 Nov 2014 06:25:07 +0000 (06:25 +0000)
includes/MovePage.php
includes/page/WikiPage.php

index 7bad3f9..e16f9ee 100644 (file)
@@ -439,6 +439,9 @@ class MovePage {
 
                $dbw = wfGetDB( DB_MASTER );
 
+               $oldpage = WikiPage::factory( $this );
+               $oldcountable = $oldpage->isCountable();
+
                $newpage = WikiPage::factory( $nt );
 
                if ( $moveOverRedirect ) {
@@ -486,7 +489,8 @@ class MovePage {
                wfRunHooks( 'NewRevisionFromEditComplete',
                        array( $newpage, $nullRevision, $nullRevision->getParentId(), $user ) );
 
-               $newpage->doEditUpdates( $nullRevision, $user, array( 'changed' => false ) );
+               $newpage->doEditUpdates( $nullRevision, $user,
+                       array( 'changed' => false, 'moved' => true, 'oldcountable' => $oldcountable ) );
 
                if ( !$moveOverRedirect ) {
                        WikiPage::onArticleCreate( $nt );
index 81c93a1..bd6fabc 100644 (file)
@@ -2142,6 +2142,7 @@ class WikiPage implements Page, IDBAccessObject {
         * @param array $options Array of options, following indexes are used:
         * - changed: boolean, whether the revision changed the content (default true)
         * - created: boolean, whether the revision created the page (default false)
+        * - moved: boolean, whether the page was moved (default false)
         * - oldcountable: boolean or null (default null):
         *   - boolean: whether the page was counted as an article before that
         *     revision, only used in changed is true and created is false
@@ -2152,7 +2153,12 @@ class WikiPage implements Page, IDBAccessObject {
 
                wfProfileIn( __METHOD__ );
 
-               $options += array( 'changed' => true, 'created' => false, 'oldcountable' => null );
+               $options += array(
+                       'changed' => true,
+                       'created' => false,
+                       'moved' => false,
+                       'oldcountable' => null
+               );
                $content = $revision->getContent();
 
                // Parse the text
@@ -2201,7 +2207,7 @@ class WikiPage implements Page, IDBAccessObject {
                $title = $this->mTitle->getPrefixedDBkey();
                $shortTitle = $this->mTitle->getDBkey();
 
-               if ( !$options['changed'] ) {
+               if ( !$options['changed'] && !$options['moved'] ) {
                        $good = 0;
                } elseif ( $options['created'] ) {
                        $good = (int)$this->isCountable( $editInfo );