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)
This commit is contained in:
Victor Vasiliev 2011-08-13 22:42:09 +00:00
parent ea24f9755f
commit 80a7648a42
4 changed files with 23 additions and 3 deletions

View file

@ -564,6 +564,16 @@ $args: arguments
$user: user
$result: result of checking autopromote condition
'BacklinkCacheGetPrefix': allows to set prefix for a spefific link table
$table: table name
&$prefix: prefix
'BacklinkCacheGetConditions': allows to set conditions for query when links to certain title
are fetched
$table: table name
$title: title of the page to which backlinks are sought
&$conds: query conditions
'BadImage': When checking against the bad image list
$name: Image name being checked
&$bad: Whether or not the image is "bad"

View file

@ -190,7 +190,13 @@ class BacklinkCache {
if ( isset( $prefixes[$table] ) ) {
return $prefixes[$table];
} else {
throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
$prefix = null;
wfRunHooks( 'BacklinkCacheGetPrefix', array( $table, &$prefix ) );
if( $prefix ) {
return $prefix;
} else {
throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
}
}
}
@ -237,7 +243,10 @@ class BacklinkCache {
);
break;
default:
throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
$conds = null;
wfRunHooks( 'BacklinkCacheGetConditions', array( $table, $this->title, &$conds ) );
if( !$conds )
throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
}
return $conds;

View file

@ -241,6 +241,7 @@ class LinksUpdate {
foreach ( $batches as $batch ) {
list( $start, $end ) = $batch;
$params = array(
'table' => 'templatelinks',
'start' => $start,
'end' => $end,
);

View file

@ -89,7 +89,7 @@ class RefreshLinksJob2 extends Job {
return false;
}
$titles = $this->title->getBacklinkCache()->getLinks(
'templatelinks', $this->params['start'], $this->params['end']);
$this->params['table'], $this->params['start'], $this->params['end']);
# Not suitable for page load triggered job running!
# Gracefully switch to refreshLinks jobs if this happens.