Fix sourceforge bug #850012 : Page move doesn't update article count
authorAntoine Musso <hashar@users.mediawiki.org>
Sat, 14 Aug 2004 20:09:47 +0000 (20:09 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Sat, 14 Aug 2004 20:09:47 +0000 (20:09 +0000)
It works on my local wiki unfortunatly I have neither memcached nor
squid so the code might need some tweaking.

includes/SpecialMovepage.php

index 1db3b34..bbb2de9 100644 (file)
@@ -110,6 +110,8 @@ class MovePageForm {
                
                # Variables beginning with 'o' for old article 'n' for new article
 
+               # Attempt to move the article
+               
                $ot = Title::newFromText( $this->oldTitle );
                $nt = Title::newFromText( $this->newTitle );
 
@@ -119,13 +121,27 @@ class MovePageForm {
                        return;
                }
                
+               # Update counters if the article got moved in or out of NS_MAIN namespace
+               $ons = $ot->getNamespace();
+               $nns = $nt->getNamespace();
+               
+               # moved out of article namespace ?
+               if ( $ons == NS_MAIN and $nns != NS_MAIN ) {
+                       $u = new SiteStatsUpdate( 0, 1, -1); # not viewed, edited, removing
+               }
+               # moved in article namespace ?
+               elseif ( $ons != NS_MAIN and $nns == NS_MAIN ) {
+                       $u = new SiteStatsUpdate( 0, 1, +1 ); # not viewed, edited, adding
+               }
+               
+               # save it for later update
+               array_push( $wgDeferredUpdateList, $u );
+               unset($u);
+               
                # Move talk page if
                # (1) the checkbox says to,
                # (2) the namespaces are not themselves talk namespaces, and of course
                # (3) it exists.
-
-               $ons = $ot->getNamespace();
-               $nns = $nt->getNamespace();
                
                if ( ( $wgRequest->getVal('wpMovetalk') == 1 ) &&
                     ( ! Namespace::isTalk( $ons ) ) &&