URL-encode the content-disposition suggested filename for XML export data.
[lhc/web/wiklou.git] / includes / LinkCache.php
index f262110..7c49d88 100644 (file)
@@ -1,13 +1,8 @@
 <?php
 /**
  * Cache for article titles (prefixed DB keys) and ids linked from one source
- * @package MediaWiki
- * @subpackage Cache
- */
-
-/**
- * @package MediaWiki
- * @subpackage Cache
+ * 
+ * @addtogroup Cache
  */
 class LinkCache {
        // Increment $mClassVer whenever old serialized versions of this class
@@ -21,7 +16,7 @@ class LinkCache {
        /**
         * Get an instance of this class
         */
-       function &singleton() {
+       static function &singleton() {
                static $instance;
                if ( !isset( $instance ) ) {
                        $instance = new LinkCache;
@@ -29,7 +24,7 @@ class LinkCache {
                return $instance;
        }
 
-       function LinkCache() {
+       function __construct() {
                $this->mForUpdate = false;
                $this->mPageLinks = array();
                $this->mGoodLinks = array();
@@ -37,8 +32,7 @@ class LinkCache {
        }
 
        /* private */ function getKey( $title ) {
-               global $wgDBname;
-               return $wgDBname.':lc:title:'.$title;
+               return wfMemcKey( 'lc', 'title', $title );
        }
 
        /**
@@ -88,10 +82,10 @@ class LinkCache {
        function getPageLinks() { return $this->mPageLinks; }
        function getGoodLinks() { return $this->mGoodLinks; }
        function getBadLinks() { return array_keys( $this->mBadLinks ); }
-       
+
        /**
         * Add a title to the link cache, return the page_id or zero if non-existent
-        * @param string $title Title to add
+        * @param $title String: title to add
         * @return integer
         */
        function addLink( $title ) {
@@ -102,10 +96,10 @@ class LinkCache {
                        return 0;
                }
        }
-       
+
        /**
         * Add a title to the link cache, return the page_id or zero if non-existent
-        * @param Title $nt Title to add
+        * @param $nt Title to add.
         * @return integer
         */
        function addLinkObj( &$nt ) {
@@ -136,14 +130,14 @@ class LinkCache {
                        $id = $wgMemc->get( $key = $this->getKey( $title ) );
                if( ! is_integer( $id ) ) {
                        if ( $this->mForUpdate ) {
-                               $db =& wfGetDB( DB_MASTER );
+                               $db = wfGetDB( DB_MASTER );
                                if ( !( $wgAntiLockFlags & ALF_NO_LINK_LOCK ) ) {
                                        $options = array( 'FOR UPDATE' );
                                } else {
                                        $options = array();
                                }
                        } else {
-                               $db =& wfGetDB( DB_SLAVE );
+                               $db = wfGetDB( DB_SLAVE );
                                $options = array();
                        }
 
@@ -175,4 +169,4 @@ class LinkCache {
                $this->mBadLinks = array();
        }
 }
-?>
+