http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97633

Revision: 97633
Author:   nikerabbit
Date:     2011-09-20 15:19:18 +0000 (Tue, 20 Sep 2011)
Log Message:
-----------
Added LinkCache::addGoodLinkObjFromRow, since addGoodLinkObj is not going to 
work much longer when new parameters are added

Modified Paths:
--------------
    trunk/phase3/includes/Title.php
    trunk/phase3/includes/WikiPage.php
    trunk/phase3/includes/cache/LinkBatch.php
    trunk/phase3/includes/cache/LinkCache.php
    trunk/phase3/includes/parser/LinkHolderArray.php

Modified: trunk/phase3/includes/Title.php
===================================================================
--- trunk/phase3/includes/Title.php     2011-09-20 15:01:19 UTC (rev 97632)
+++ trunk/phase3/includes/Title.php     2011-09-20 15:19:18 UTC (rev 97633)
@@ -2918,7 +2918,7 @@
                        foreach ( $res as $row ) {
                                $titleObj = Title::makeTitle( 
$row->page_namespace, $row->page_title );
                                if ( $titleObj ) {
-                                       $linkCache->addGoodLinkObj( 
$row->page_id, $titleObj, $row->page_len, $row->page_is_redirect, 
$row->page_latest );
+                                       $linkCache->addGoodLinkObjFromRow( 
$titleObj, $row );
                                        $retVal[] = $titleObj;
                                }
                        }

Modified: trunk/phase3/includes/WikiPage.php
===================================================================
--- trunk/phase3/includes/WikiPage.php  2011-09-20 15:01:19 UTC (rev 97632)
+++ trunk/phase3/includes/WikiPage.php  2011-09-20 15:19:18 UTC (rev 97633)
@@ -371,8 +371,7 @@
                $lc = LinkCache::singleton();
 
                if ( $data ) {
-                       $lc->addGoodLinkObj( $data->page_id, $this->mTitle,
-                               $data->page_len, $data->page_is_redirect, 
$data->page_latest );
+                       $lc->addGoodLinkObjFromRow( $this->mTitle, $data );
 
                        $this->mTitle->loadFromRow( $data );
 

Modified: trunk/phase3/includes/cache/LinkBatch.php
===================================================================
--- trunk/phase3/includes/cache/LinkBatch.php   2011-09-20 15:01:19 UTC (rev 
97632)
+++ trunk/phase3/includes/cache/LinkBatch.php   2011-09-20 15:19:18 UTC (rev 
97633)
@@ -126,7 +126,7 @@
                $remaining = $this->data;
                foreach ( $res as $row ) {
                        $title = Title::makeTitle( $row->page_namespace, 
$row->page_title );
-                       $cache->addGoodLinkObj( $row->page_id, $title, 
$row->page_len, $row->page_is_redirect, $row->page_latest );
+                       $cache->addGoodLinkObjFromRow( $title, $row );
                        $ids[$title->getPrefixedDBkey()] = $row->page_id;
                        unset( 
$remaining[$row->page_namespace][$row->page_title] );
                }

Modified: trunk/phase3/includes/cache/LinkCache.php
===================================================================
--- trunk/phase3/includes/cache/LinkCache.php   2011-09-20 15:01:19 UTC (rev 
97632)
+++ trunk/phase3/includes/cache/LinkCache.php   2011-09-20 15:19:18 UTC (rev 
97633)
@@ -96,8 +96,25 @@
        }
 
        /**
+        * Same as above with better interface.
+        * @since 1.19
         * @param $title Title
+        * @param $row object which has the fields page_id, page_is_redirect,
+        *  page_latest
         */
+       public function addGoodLinkObjFromRow( $title, $row ) {
+               $dbkey = $title->getPrefixedDbKey();
+               $this->mGoodLinks[$dbkey] = intval( $row->page_id );
+               $this->mGoodLinkFields[$dbkey] = array(
+                       'length' => intval( $row->page_len ),
+                       'redirect' => intval( $row->page_is_redirect ),
+                       'revision' => intval( $row->page_latest ),
+               );
+       }
+
+       /**
+        * @param $title Title
+        */
        public function addBadLinkObj( $title ) {
                $dbkey = $title->getPrefixedDbKey();
                if ( !$this->isBadLink( $dbkey ) ) {
@@ -182,22 +199,11 @@
                        __METHOD__, $options );
                # Set fields...
                if ( $s !== false ) {
-                       $id = intval( $s->page_id );
-                       $len = intval( $s->page_len );
-                       $redirect = intval( $s->page_is_redirect );
-                       $revision = intval( $s->page_latest );
+                       $this->addGoodLinkObjFromRow( $nt, $s );
                } else {
-                       $id = 0;
-                       $len = -1;
-                       $redirect = 0;
-                       $revision = 0;
+                       $this->addBadLinkObj( $nt );
                }
 
-               if ( $id == 0 ) {
-                       $this->addBadLinkObj( $nt );
-               } else {
-                       $this->addGoodLinkObj( $id, $nt, $len, $redirect, 
$revision );
-               }
                wfProfileOut( __METHOD__ );
                return $id;
        }

Modified: trunk/phase3/includes/parser/LinkHolderArray.php
===================================================================
--- trunk/phase3/includes/parser/LinkHolderArray.php    2011-09-20 15:01:19 UTC 
(rev 97632)
+++ trunk/phase3/includes/parser/LinkHolderArray.php    2011-09-20 15:19:18 UTC 
(rev 97633)
@@ -320,7 +320,7 @@
                        foreach ( $res as $s ) {
                                $title = Title::makeTitle( $s->page_namespace, 
$s->page_title );
                                $pdbk = $title->getPrefixedDBkey();
-                               $linkCache->addGoodLinkObj( $s->page_id, 
$title, $s->page_len, $s->page_is_redirect, $s->page_latest );
+                               $linkCache->addGoodLinkObjFromRow( $title, $s );
                                $output->addLink( $title, $s->page_id );
                                # @todo FIXME: Convoluted data flow
                                # The redirect status and length is passed to 
getLinkColour via the LinkCache
@@ -490,7 +490,7 @@
                        // construct query
                        $dbr = wfGetDB( DB_SLAVE );
                        $varRes = $dbr->select( 'page',
-                               array( 'page_id', 'page_namespace', 
'page_title', 'page_is_redirect', 'page_len' ),
+                               array( 'page_id', 'page_namespace', 
'page_title', 'page_is_redirect', 'page_len', 'page_latest' ),
                                $linkBatch->constructSet( 'page', $dbr ),
                                __METHOD__
                        );
@@ -507,7 +507,7 @@
                                $holderKeys = array();
                                if( isset( $variantMap[$varPdbk] ) ) {
                                        $holderKeys = $variantMap[$varPdbk];
-                                       $linkCache->addGoodLinkObj( 
$s->page_id, $variantTitle, $s->page_len, $s->page_is_redirect );
+                                       $linkCache->addGoodLinkObjFromRow( 
$variantTitle, $s );
                                        $output->addLink( $variantTitle, 
$s->page_id );
                                }
 


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

Reply via email to