Hashar has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/64564


Change subject: LinkCache singleton can now be altered
......................................................................

LinkCache singleton can now be altered

This patch adds the ability to destroy the LinkCache singleton or to
replace the instance with a different object.  Note the $instance static
variable is now at the class level instead of at the method level.

Change-Id: Ib110ad061868834a52a6bac651976b3ffab4a6ce
---
M RELEASE-NOTES-1.22
M includes/cache/LinkCache.php
2 files changed, 31 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/64/64564/1

diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index 168f2f7..ecae92c 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -79,6 +79,8 @@
   which can be cascading (previously 'sysop' was hard-coded as the only one).
 * XHTML5 support has been improved. If you set $wgMimeType = 
'application/xhtml+xml'
   MediaWiki will try outputting markup acording to XHTML5 rules.
+* LinkCache singleton can now be altered or cleared, letting one to specify
+  another instance that does not rely on a database backend.
 
 === Bug fixes in 1.22 ===
 * Disable Special:PasswordReset when $wgEnableEmail is false. Previously one
diff --git a/includes/cache/LinkCache.php b/includes/cache/LinkCache.php
index 31982e0..9dbab2c 100644
--- a/includes/cache/LinkCache.php
+++ b/includes/cache/LinkCache.php
@@ -37,16 +37,40 @@
        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.
+        * @since 1.22
+        */
+       static function setSingleton( $instance ) {
+               self::$instance = $instance;
        }
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib110ad061868834a52a6bac651976b3ffab4a6ce
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Hashar <[email protected]>

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

Reply via email to