jenkins-bot has submitted this change and it was merged.

Change subject: Update article count when pages are moved
......................................................................


Update article count when pages are moved

If a page is no longer countable (or becomes newly countable) after a move,
we need to update the site statistics (count of content pages).

Bug: 64333
Change-Id: I0349cfe0e32229706e01d654aacf8ccbe5ebabf3
---
M includes/MovePage.php
M includes/page/WikiPage.php
2 files changed, 13 insertions(+), 3 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/MovePage.php b/includes/MovePage.php
index 79095e9..beea776 100644
--- a/includes/MovePage.php
+++ b/includes/MovePage.php
@@ -342,6 +342,9 @@
 
                $dbw = wfGetDB( DB_MASTER );
 
+               $oldpage = WikiPage::factory( $this );
+               $oldcountable = $oldpage->isCountable();
+
                $newpage = WikiPage::factory( $nt );
 
                if ( $moveOverRedirect ) {
@@ -389,7 +392,8 @@
                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 );
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 81c93a1..bd6fabc 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -2142,6 +2142,7 @@
         * @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 @@
 
                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 @@
                $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 );

-- 
To view, visit https://gerrit.wikimedia.org/r/148585
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0349cfe0e32229706e01d654aacf8ccbe5ebabf3
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: TTO <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Calak <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: TTO <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to