* Select len,is_redirect too
authorAaron Schulz <aaron@users.mediawiki.org>
Wed, 9 Apr 2008 13:02:34 +0000 (13:02 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Wed, 9 Apr 2008 13:02:34 +0000 (13:02 +0000)
* Make visibility of linkcache stuff clearer

includes/LinkBatch.php
includes/LinkCache.php
includes/OutputPage.php

index 746092e..90ed33a 100644 (file)
@@ -18,7 +18,7 @@ class LinkBatch {
                }
        }
 
-       function addObj( $title ) {
+       public function addObj( $title ) {
                if ( is_object( $title ) ) {
                        $this->add( $title->getNamespace(), $title->getDBkey() );
                } else {
@@ -26,7 +26,7 @@ class LinkBatch {
                }
        }
 
-       function add( $ns, $dbkey ) {
+       public function add( $ns, $dbkey ) {
                if ( $ns < 0 ) {
                        return;
                }
@@ -41,21 +41,21 @@ class LinkBatch {
         * Set the link list to a given 2-d array
         * First key is the namespace, second is the DB key, value arbitrary
         */
-       function setArray( $array ) {
+       public function setArray( $array ) {
                $this->data = $array;
        }
 
        /**
         * Returns true if no pages have been added, false otherwise.
         */
-       function isEmpty() {
+       public function isEmpty() {
                return ($this->getSize() == 0);
        }
 
        /**
         * Returns the size of the batch.
         */
-       function getSize() {
+       public function getSize() {
                return count( $this->data );
        }
 
@@ -63,7 +63,7 @@ class LinkBatch {
         * Do the query and add the results to the LinkCache object
         * Return an array mapping PDBK to ID
         */
-        function execute() {
+        public function execute() {
                $linkCache =& LinkCache::singleton();
                return $this->executeInto( $linkCache );
         }
@@ -72,7 +72,7 @@ class LinkBatch {
         * Do the query and add the results to a given LinkCache object
         * Return an array mapping PDBK to ID
         */
-       function executeInto( &$cache ) {
+       protected function executeInto( &$cache ) {
                wfProfileIn( __METHOD__ );
                $res = $this->doQuery();
                $ids = $this->addResultToCache( $cache, $res );
@@ -86,7 +86,7 @@ class LinkBatch {
         * This function *also* stores extra fields of the title used for link 
         * parsing to avoid extra DB queries.
         */
-       function addResultToCache( $cache, $res ) {
+       public function addResultToCache( $cache, $res ) {
                if ( !$res ) {
                        return array();
                }
@@ -116,7 +116,7 @@ class LinkBatch {
        /**
         * Perform the existence test query, return a ResultWrapper with page_id fields
         */
-       function doQuery() {
+       public function doQuery() {
                if ( $this->isEmpty() ) {
                        return false;
                }
@@ -146,7 +146,7 @@ class LinkBatch {
         * @return string
         * @public
         */
-       function constructSet( $prefix, &$db ) {
+       public function constructSet( $prefix, &$db ) {
                $first = true;
                $firstTitle = true;
                $sql = '';
index 4b3ba0d..5ce0133 100644 (file)
@@ -32,18 +32,18 @@ class LinkCache {
                $this->mBadLinks = array();
        }
 
-       /* private */ function getKey( $title ) {
+       private function getKey( $title ) {
                return wfMemcKey( 'lc', 'title', $title );
        }
 
        /**
         * General accessor to get/set whether SELECT FOR UPDATE should be used
         */
-       function forUpdate( $update = NULL ) {
+       public function forUpdate( $update = NULL ) {
                return wfSetVar( $this->mForUpdate, $update );
        }
 
-       function getGoodLinkID( $title ) {
+       public function getGoodLinkID( $title ) {
                if ( array_key_exists( $title, $this->mGoodLinks ) ) {
                        return $this->mGoodLinks[$title];
                } else {
@@ -58,7 +58,7 @@ class LinkCache {
         * @param string $field ('length','redirect')
         * @return mixed
         */
-       function getGoodLinkFieldObj( $title, $field ) {
+       public function getGoodLinkFieldObj( $title, $field ) {
                $dbkey = $title->getPrefixedDbKey();
                if ( array_key_exists( $dbkey, $this->mGoodLinkFields ) ) {
                        return $this->mGoodLinkFields[$dbkey][$field];
@@ -67,7 +67,7 @@ class LinkCache {
                }
        }
 
-       function isBadLink( $title ) {
+       public function isBadLink( $title ) {
                return array_key_exists( $title, $this->mBadLinks );
        }
 
@@ -78,14 +78,14 @@ class LinkCache {
         * @param int $len
         * @param int $redir
         */
-       function addGoodLinkObj( $id, $title, $len = -1, $redir = NULL ) {
+       public function addGoodLinkObj( $id, $title, $len = -1, $redir = NULL ) {
                $dbkey = $title->getPrefixedDbKey();
                $this->mGoodLinks[$dbkey] = $id;
                $this->mGoodLinkFields[$dbkey] = array( 'length' => $len, 'redirect' => $redir );
                $this->mPageLinks[$dbkey] = $title;
        }
 
-       function addBadLinkObj( $title ) {
+       public function addBadLinkObj( $title ) {
                $dbkey = $title->getPrefixedDbKey();
                if ( ! $this->isBadLink( $dbkey ) ) {
                        $this->mBadLinks[$dbkey] = 1;
@@ -93,20 +93,20 @@ class LinkCache {
                }
        }
 
-       function clearBadLink( $title ) {
+       public function clearBadLink( $title ) {
                unset( $this->mBadLinks[$title] );
                $this->clearLink( $title );
        }
 
-       function clearLink( $title ) {
+       public function clearLink( $title ) {
                global $wgMemc, $wgLinkCacheMemcached;
                if( $wgLinkCacheMemcached )
                        $wgMemc->delete( $this->getKey( $title ) );
        }
 
-       function getPageLinks() { return $this->mPageLinks; }
-       function getGoodLinks() { return $this->mGoodLinks; }
-       function getBadLinks() { return array_keys( $this->mBadLinks ); }
+       public function getPageLinks() { return $this->mPageLinks; }
+       public function getGoodLinks() { return $this->mGoodLinks; }
+       public function getBadLinks() { return array_keys( $this->mBadLinks ); }
 
        /**
         * Add a title to the link cache, return the page_id or zero if non-existent
@@ -115,7 +115,7 @@ class LinkCache {
         * @param $redir bool, is redirect?
         * @return integer
         */
-       function addLink( $title, $len = -1, $redir = NULL ) {
+       public function addLink( $title, $len = -1, $redir = NULL ) {
                $nt = Title::newFromDBkey( $title );
                if( $nt ) {
                        return $this->addLinkObj( $nt, $len, $redir );
@@ -131,7 +131,7 @@ class LinkCache {
         * @param $redir bool, is redirect?
         * @return integer
         */
-       function addLinkObj( &$nt, $len = -1, $redirect = NULL ) {
+       public function addLinkObj( &$nt, $len = -1, $redirect = NULL ) {
                global $wgMemc, $wgLinkCacheMemcached, $wgAntiLockFlags;
                $title = $nt->getPrefixedDBkey();
                if ( $this->isBadLink( $title ) ) { return 0; }
@@ -198,7 +198,7 @@ class LinkCache {
        /**
         * Clears cache
         */
-       function clear() {
+       public function clear() {
                $this->mPageLinks = array();
                $this->mGoodLinks = array();
                $this->mGoodLinkFields = array();
index 482174b..8bfb7e6 100644 (file)
@@ -287,8 +287,8 @@ class OutputPage {
                $pageTable = $dbr->tableName( 'page' );
                $where = $lb->constructSet( 'page', $dbr );
                $propsTable = $dbr->tableName( 'page_props' );
-               $sql = "SELECT page_id, page_namespace, page_title, pp_value FROM $pageTable LEFT JOIN $propsTable " . 
-                       " ON pp_propname='hiddencat' AND pp_page=page_id WHERE $where";
+               $sql = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect, pp_value
+                       FROM $pageTable LEFT JOIN $propsTable ON pp_propname='hiddencat' AND pp_page=page_id WHERE $where";
                $res = $dbr->query( $sql, __METHOD__ );
 
                # Add the results to the link cache