Clear SiteStats process cache after DB update
authorTim Starling <tstarling@wikimedia.org>
Thu, 25 Aug 2016 01:37:38 +0000 (11:37 +1000)
committerTim Starling <tstarling@wikimedia.org>
Thu, 25 Aug 2016 01:44:10 +0000 (11:44 +1000)
This fixes a phpunit test error, wherein {{NUMBEROFFILES}} would give
the number of files in the host wiki, not in the temporary database,
when Scribunto was installed, due to a Scribunto phpunit data provider
calling SiteStats::pages().

Change-Id: Ic0d021a72addaa2a13a6b94fd34dccc423de3a8f

includes/SiteStats.php
includes/deferred/SiteStatsUpdate.php

index 03b4b8c..604ab93 100644 (file)
@@ -36,6 +36,10 @@ class SiteStats {
        /** @var int[] */
        private static $pageCount = [];
 
+       static function unload() {
+               self::$loaded = false;
+       }
+
        static function recache() {
                self::load( true );
        }
index b8e2726..30aae15 100644 (file)
@@ -122,6 +122,9 @@ class SiteStatsUpdate implements DeferrableUpdate {
                        // Commit the updates and unlock the table
                        $dbw->unlock( $lockKey, __METHOD__ );
                }
+
+               // Invalid cache used by parser functions
+               SiteStats::unload();
        }
 
        /**
@@ -152,6 +155,9 @@ class SiteStatsUpdate implements DeferrableUpdate {
                        __METHOD__
                );
 
+               // Invalid cache used by parser functions
+               SiteStats::unload();
+
                return $activeUsers;
        }