r94435 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94434‎ | r94435 | r94436 >
Date:22:42, 13 August 2011
Author:vasilievvv
Status:resolved
Tags:
Comment:
Allow extensions to run their own backlink-based updates:
* Introduce new hooks which allow BacklinkCache to handle non-core tables
* Make table name a parameter to RefreshLinks2 job (instead of hardcoded templatelinks)
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/BacklinkCache.php (modified) (history)
  • /trunk/phase3/includes/LinksUpdate.php (modified) (history)
  • /trunk/phase3/includes/job/RefreshLinksJob.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -564,6 +564,16 @@
565565 $user: user
566566 $result: result of checking autopromote condition
567567
 568+'BacklinkCacheGetPrefix': allows to set prefix for a spefific link table
 569+$table: table name
 570+&$prefix: prefix
 571+
 572+'BacklinkCacheGetConditions': allows to set conditions for query when links to certain title
 573+are fetched
 574+$table: table name
 575+$title: title of the page to which backlinks are sought
 576+&$conds: query conditions
 577+
568578 'BadImage': When checking against the bad image list
569579 $name: Image name being checked
570580 &$bad: Whether or not the image is "bad"
Index: trunk/phase3/includes/LinksUpdate.php
@@ -241,6 +241,7 @@
242242 foreach ( $batches as $batch ) {
243243 list( $start, $end ) = $batch;
244244 $params = array(
 245+ 'table' => 'templatelinks',
245246 'start' => $start,
246247 'end' => $end,
247248 );
Index: trunk/phase3/includes/BacklinkCache.php
@@ -190,7 +190,13 @@
191191 if ( isset( $prefixes[$table] ) ) {
192192 return $prefixes[$table];
193193 } else {
194 - throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
 194+ $prefix = null;
 195+ wfRunHooks( 'BacklinkCacheGetPrefix', array( $table, &$prefix ) );
 196+ if( $prefix ) {
 197+ return $prefix;
 198+ } else {
 199+ throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
 200+ }
195201 }
196202 }
197203
@@ -237,7 +243,10 @@
238244 );
239245 break;
240246 default:
241 - throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
 247+ $conds = null;
 248+ wfRunHooks( 'BacklinkCacheGetConditions', array( $table, $this->title, &$conds ) );
 249+ if( !$conds )
 250+ throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
242251 }
243252
244253 return $conds;
Index: trunk/phase3/includes/job/RefreshLinksJob.php
@@ -89,7 +89,7 @@
9090 return false;
9191 }
9292 $titles = $this->title->getBacklinkCache()->getLinks(
93 - 'templatelinks', $this->params['start'], $this->params['end']);
 93+ $this->params['table'], $this->params['start'], $this->params['end']);
9494
9595 # Not suitable for page load triggered job running!
9696 # Gracefully switch to refreshLinks jobs if this happens.

Sign-offs

UserFlagDate
Catropeinspected09:59, 14 August 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r96831Followup r94435: don't barf on jobs inserted before this revision that don't ...catrope10:18, 12 September 2011

Status & tagging log