Merge "Adding a quotation marks message to core."
[lhc/web/wiklou.git] / includes / cache / LinkCache.php
index 31982e0..6ac7e7a 100644 (file)
@@ -37,16 +37,41 @@ class LinkCache {
        private $mForUpdate = false;
 
        /**
-        * Get an instance of this class
+        * @var LinkCache
+        */
+       protected static $instance;
+
+       /**
+        * Get an instance of this class.
         *
         * @return LinkCache
         */
        static function &singleton() {
-               static $instance;
-               if ( !isset( $instance ) ) {
-                       $instance = new LinkCache;
+               if ( self::$instance ) {
+                       return self::$instance;
                }
-               return $instance;
+               self::$instance = new LinkCache;
+               return self::$instance;
+       }
+
+       /**
+        * Destroy the singleton instance, a new one will be created next time
+        * singleton() is called.
+        * @since 1.22
+        */
+       static function destroySingleton() {
+               self::$instance = null;
+       }
+
+       /**
+        * Set the singleton instance to a given object.
+        * Since we do not have an interface for LinkCache, you have to be sure the
+        * given object implements all the LinkCache public methods.
+        * @param LinkCache $instance
+        * @since 1.22
+        */
+       static function setSingleton( LinkCache $instance ) {
+               self::$instance = $instance;
        }
 
        /**