Index: trunk/phase3/includes/parser/LinkHolderArray.php |
— | — | @@ -320,7 +320,7 @@ |
321 | 321 | foreach ( $res as $s ) { |
322 | 322 | $title = Title::makeTitle( $s->page_namespace, $s->page_title ); |
323 | 323 | $pdbk = $title->getPrefixedDBkey(); |
324 | | - $linkCache->addGoodLinkObj( $s->page_id, $title, $s->page_len, $s->page_is_redirect, $s->page_latest ); |
| 324 | + $linkCache->addGoodLinkObjFromRow( $title, $s ); |
325 | 325 | $output->addLink( $title, $s->page_id ); |
326 | 326 | # @todo FIXME: Convoluted data flow |
327 | 327 | # The redirect status and length is passed to getLinkColour via the LinkCache |
— | — | @@ -490,7 +490,7 @@ |
491 | 491 | // construct query |
492 | 492 | $dbr = wfGetDB( DB_SLAVE ); |
493 | 493 | $varRes = $dbr->select( 'page', |
494 | | - array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len' ), |
| 494 | + array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest' ), |
495 | 495 | $linkBatch->constructSet( 'page', $dbr ), |
496 | 496 | __METHOD__ |
497 | 497 | ); |
— | — | @@ -507,7 +507,7 @@ |
508 | 508 | $holderKeys = array(); |
509 | 509 | if( isset( $variantMap[$varPdbk] ) ) { |
510 | 510 | $holderKeys = $variantMap[$varPdbk]; |
511 | | - $linkCache->addGoodLinkObj( $s->page_id, $variantTitle, $s->page_len, $s->page_is_redirect ); |
| 511 | + $linkCache->addGoodLinkObjFromRow( $variantTitle, $s ); |
512 | 512 | $output->addLink( $variantTitle, $s->page_id ); |
513 | 513 | } |
514 | 514 | |
Index: trunk/phase3/includes/cache/LinkBatch.php |
— | — | @@ -126,7 +126,7 @@ |
127 | 127 | $remaining = $this->data; |
128 | 128 | foreach ( $res as $row ) { |
129 | 129 | $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
130 | | - $cache->addGoodLinkObj( $row->page_id, $title, $row->page_len, $row->page_is_redirect, $row->page_latest ); |
| 130 | + $cache->addGoodLinkObjFromRow( $title, $row ); |
131 | 131 | $ids[$title->getPrefixedDBkey()] = $row->page_id; |
132 | 132 | unset( $remaining[$row->page_namespace][$row->page_title] ); |
133 | 133 | } |
Index: trunk/phase3/includes/cache/LinkCache.php |
— | — | @@ -96,8 +96,25 @@ |
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
| 100 | + * Same as above with better interface. |
| 101 | + * @since 1.19 |
100 | 102 | * @param $title Title |
| 103 | + * @param $row object which has the fields page_id, page_is_redirect, |
| 104 | + * page_latest |
101 | 105 | */ |
| 106 | + public function addGoodLinkObjFromRow( $title, $row ) { |
| 107 | + $dbkey = $title->getPrefixedDbKey(); |
| 108 | + $this->mGoodLinks[$dbkey] = intval( $row->page_id ); |
| 109 | + $this->mGoodLinkFields[$dbkey] = array( |
| 110 | + 'length' => intval( $row->page_len ), |
| 111 | + 'redirect' => intval( $row->page_is_redirect ), |
| 112 | + 'revision' => intval( $row->page_latest ), |
| 113 | + ); |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * @param $title Title |
| 118 | + */ |
102 | 119 | public function addBadLinkObj( $title ) { |
103 | 120 | $dbkey = $title->getPrefixedDbKey(); |
104 | 121 | if ( !$this->isBadLink( $dbkey ) ) { |
— | — | @@ -182,22 +199,11 @@ |
183 | 200 | __METHOD__, $options ); |
184 | 201 | # Set fields... |
185 | 202 | if ( $s !== false ) { |
186 | | - $id = intval( $s->page_id ); |
187 | | - $len = intval( $s->page_len ); |
188 | | - $redirect = intval( $s->page_is_redirect ); |
189 | | - $revision = intval( $s->page_latest ); |
| 203 | + $this->addGoodLinkObjFromRow( $nt, $s ); |
190 | 204 | } else { |
191 | | - $id = 0; |
192 | | - $len = -1; |
193 | | - $redirect = 0; |
194 | | - $revision = 0; |
| 205 | + $this->addBadLinkObj( $nt ); |
195 | 206 | } |
196 | 207 | |
197 | | - if ( $id == 0 ) { |
198 | | - $this->addBadLinkObj( $nt ); |
199 | | - } else { |
200 | | - $this->addGoodLinkObj( $id, $nt, $len, $redirect, $revision ); |
201 | | - } |
202 | 208 | wfProfileOut( __METHOD__ ); |
203 | 209 | return $id; |
204 | 210 | } |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -2918,7 +2918,7 @@ |
2919 | 2919 | foreach ( $res as $row ) { |
2920 | 2920 | $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title ); |
2921 | 2921 | if ( $titleObj ) { |
2922 | | - $linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redirect, $row->page_latest ); |
| 2922 | + $linkCache->addGoodLinkObjFromRow( $titleObj, $row ); |
2923 | 2923 | $retVal[] = $titleObj; |
2924 | 2924 | } |
2925 | 2925 | } |
Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -371,8 +371,7 @@ |
372 | 372 | $lc = LinkCache::singleton(); |
373 | 373 | |
374 | 374 | if ( $data ) { |
375 | | - $lc->addGoodLinkObj( $data->page_id, $this->mTitle, |
376 | | - $data->page_len, $data->page_is_redirect, $data->page_latest ); |
| 375 | + $lc->addGoodLinkObjFromRow( $this->mTitle, $data ); |
377 | 376 | |
378 | 377 | $this->mTitle->loadFromRow( $data ); |
379 | 378 | |