r97633 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97632‎ | r97633 | r97634 >
Date:15:19, 20 September 2011
Author:nikerabbit
Status:resolved (Comments)
Tags:
Comment:
Added LinkCache::addGoodLinkObjFromRow, since addGoodLinkObj is not going to work much longer when new parameters are added
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/WikiPage.php (modified) (history)
  • /trunk/phase3/includes/cache/LinkBatch.php (modified) (history)
  • /trunk/phase3/includes/cache/LinkCache.php (modified) (history)
  • /trunk/phase3/includes/parser/LinkHolderArray.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/LinkHolderArray.php
@@ -320,7 +320,7 @@
321321 foreach ( $res as $s ) {
322322 $title = Title::makeTitle( $s->page_namespace, $s->page_title );
323323 $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 );
325325 $output->addLink( $title, $s->page_id );
326326 # @todo FIXME: Convoluted data flow
327327 # The redirect status and length is passed to getLinkColour via the LinkCache
@@ -490,7 +490,7 @@
491491 // construct query
492492 $dbr = wfGetDB( DB_SLAVE );
493493 $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' ),
495495 $linkBatch->constructSet( 'page', $dbr ),
496496 __METHOD__
497497 );
@@ -507,7 +507,7 @@
508508 $holderKeys = array();
509509 if( isset( $variantMap[$varPdbk] ) ) {
510510 $holderKeys = $variantMap[$varPdbk];
511 - $linkCache->addGoodLinkObj( $s->page_id, $variantTitle, $s->page_len, $s->page_is_redirect );
 511+ $linkCache->addGoodLinkObjFromRow( $variantTitle, $s );
512512 $output->addLink( $variantTitle, $s->page_id );
513513 }
514514
Index: trunk/phase3/includes/cache/LinkBatch.php
@@ -126,7 +126,7 @@
127127 $remaining = $this->data;
128128 foreach ( $res as $row ) {
129129 $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 );
131131 $ids[$title->getPrefixedDBkey()] = $row->page_id;
132132 unset( $remaining[$row->page_namespace][$row->page_title] );
133133 }
Index: trunk/phase3/includes/cache/LinkCache.php
@@ -96,8 +96,25 @@
9797 }
9898
9999 /**
 100+ * Same as above with better interface.
 101+ * @since 1.19
100102 * @param $title Title
 103+ * @param $row object which has the fields page_id, page_is_redirect,
 104+ * page_latest
101105 */
 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+ */
102119 public function addBadLinkObj( $title ) {
103120 $dbkey = $title->getPrefixedDbKey();
104121 if ( !$this->isBadLink( $dbkey ) ) {
@@ -182,22 +199,11 @@
183200 __METHOD__, $options );
184201 # Set fields...
185202 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 );
190204 } else {
191 - $id = 0;
192 - $len = -1;
193 - $redirect = 0;
194 - $revision = 0;
 205+ $this->addBadLinkObj( $nt );
195206 }
196207
197 - if ( $id == 0 ) {
198 - $this->addBadLinkObj( $nt );
199 - } else {
200 - $this->addGoodLinkObj( $id, $nt, $len, $redirect, $revision );
201 - }
202208 wfProfileOut( __METHOD__ );
203209 return $id;
204210 }
Index: trunk/phase3/includes/Title.php
@@ -2918,7 +2918,7 @@
29192919 foreach ( $res as $row ) {
29202920 $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title );
29212921 if ( $titleObj ) {
2922 - $linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redirect, $row->page_latest );
 2922+ $linkCache->addGoodLinkObjFromRow( $titleObj, $row );
29232923 $retVal[] = $titleObj;
29242924 }
29252925 }
Index: trunk/phase3/includes/WikiPage.php
@@ -371,8 +371,7 @@
372372 $lc = LinkCache::singleton();
373373
374374 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 );
377376
378377 $this->mTitle->loadFromRow( $data );
379378

Follow-up revisions

RevisionCommit summaryAuthorDate
r97641I broke few parser tests in r97633 by overlooking the return value. This fixe...nikerabbit16:26, 20 September 2011

Comments

#Comment by Catrope (talk | contribs)   15:51, 20 September 2011

Breaks parser tests. On my machine:

Running test Edit comment with section link (non-local, eg in history list)... FAILED!
Running test Space normalisation on autocomment ([https://bugzilla.wikimedia.org/show_bug.cgi?id=22784 bug 22784])... FAILED!

On Jenkins, these tests pass but three different tests fail. Also, the test run time has suddenly increased from ~3 to ~19 mins.

Status & tagging log