Make Sites::singleton() actually return a singleton.
authordaniel <daniel.kinzler@wikimedia.de>
Thu, 31 Jan 2013 14:33:22 +0000 (15:33 +0100)
committerdaniel <daniel.kinzler@wikimedia.de>
Thu, 31 Jan 2013 14:33:22 +0000 (15:33 +0100)
Sites::singleton() was returning a new instance for every call,
rendering in-process caching ineffective. This was causing extreme
slowness on some configurations (about factor 100).

Change-Id: I1e28afea8710b44542c55db150ad37518a5a5df1

includes/site/SiteSQLStore.php

index a79c8c5..c462057 100644 (file)
@@ -466,7 +466,13 @@ class Sites extends SiteSQLStore {
         * @return SiteStore
         */
        public static function singleton() {
-               return new static();
+               static $singleton;
+
+               if ( $singleton === null ) {
+                       $singleton = new static();
+               }
+
+               return $singleton;
        }
 
        /**