// Reparse any pages transcluding this page
LinksUpdate::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );
+ // Reparse any pages including this image
+ if ( $this->mTitle->getNamespace() == NS_FILE ) {
+ LinksUpdate::queueRecursiveJobsForTable( $this->mTitle, 'imagelinks' );
+ }
+
// Clear caches
WikiPage::onArticleDelete( $this->mTitle );
return;
}
- // templatelinks table may have become out of sync,
+ // templatelinks or imagelinks tables may have become out of sync,
// especially if using variable-based transclusions.
// For paranoia, check if things have changed and if
// so apply updates to the database. This will ensure
// that cascaded protections apply as soon as the changes
// are visible.
- // Get templates from templatelinks
+ // Get templates from templatelinks and images from imagelinks
$id = $this->getId();
- $tlTemplates = array();
+ $dbLinks = array();
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( array( 'templatelinks' ),
);
foreach ( $res as $row ) {
- $tlTemplates["{$row->tl_namespace}:{$row->tl_title}"] = true;
+ $dbLinks["{$row->tl_namespace}:{$row->tl_title}"] = true;
+ }
+
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select( array( 'imagelinks' ),
+ array( 'il_to' ),
+ array( 'il_from' => $id ),
+ __METHOD__
+ );
+
+ foreach ( $res as $row ) {
+ $dbLinks[NS_FILE . ":{$row->il_to}"] = true;
}
- // Get templates from parser output.
- $poTemplates = array();
+ // Get templates and images from parser output.
+ $poLinks = array();
foreach ( $parserOutput->getTemplates() as $ns => $templates ) {
foreach ( $templates as $dbk => $id ) {
- $poTemplates["$ns:$dbk"] = true;
+ $poLinks["$ns:$dbk"] = true;
}
}
+ foreach ( $parserOutput->getImages() as $dbk => $id ) {
+ $poLinks[NS_FILE . ":$dbk"] = true;
+ }
// Get the diff
- $templates_diff = array_diff_key( $poTemplates, $tlTemplates );
+ $links_diff = array_diff_key( $poLinks, $dbLinks );
- if ( count( $templates_diff ) > 0 ) {
+ if ( count( $links_diff ) > 0 ) {
// Whee, link updates time.
// Note: we are only interested in links here. We don't need to get other DataUpdate items from the parser output.
$u = new LinksUpdate( $this->mTitle, $parserOutput, false );
/**
* Queue recursive jobs for this page
*
- * Which means do LinksUpdate on all templates
- * that include the current page, using the job queue.
+ * Which means do LinksUpdate on all pages that include the current page,
+ * using the job queue.
*/
function queueRecursiveJobs() {
self::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );
+ if ( $this->mTitle->getNamespace() == NS_FILE ) {
+ // Process imagelinks in case the title is or was a redirect
+ self::queueRecursiveJobsForTable( $this->mTitle, 'imagelinks' );
+ }
}
/**
LinksUpdate::queueRecursiveJobsForTable( $this->getTitle(), 'imagelinks' );
}
- # Invalidate cache for all pages that redirects on this page
- $redirs = $this->getTitle()->getRedirectsHere();
-
- foreach ( $redirs as $redir ) {
- if ( !$reupload && $redir->getNamespace() === NS_FILE ) {
- LinksUpdate::queueRecursiveJobsForTable( $redir, 'imagelinks' );
- }
- $update = new HTMLCacheUpdate( $redir, 'imagelinks' );
- $update->doUpdate();
- }
-
wfProfileOut( __METHOD__ );
return true;
if ( $file && !$title->equals( $file->getTitle() ) ) {
# Update fetched file title
$title = $file->getTitle();
- if ( is_null( $file->getRedirectedTitle() ) ) {
- # This file was not a redirect, but the title does not match.
- # Register under the new name because otherwise the link will
- # get lost.
- $this->mOutput->addImage( $title->getDBkey(), $time, $sha1 );
- }
+ $this->mOutput->addImage( $title->getDBkey(), $time, $sha1 );
}
return array( $file, $title );
}