* Invalidate cache of pages that includes images via redirects on upload
authorVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sat, 12 Apr 2008 18:06:57 +0000 (18:06 +0000)
committerVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sat, 12 Apr 2008 18:06:57 +0000 (18:06 +0000)
RELEASE-NOTES
includes/Title.php
includes/filerepo/LocalFile.php

index 779ecc8..8b35a6c 100644 (file)
@@ -73,6 +73,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 6934) Allow separated inclusions, links, redirects on whatlinkshere
 * Add a footer (emailuser-footer) to the bottom of messages sent with
 Special:EmailUser
+* Cache image redirects
 
 === Bug fixes in 1.13 ===
 
@@ -174,6 +175,7 @@ Special:EmailUser
 * (bug 13684) Links in Special:ListGroupRights should be in content language
 * (bug 13690) Fix PHP notice on accessing some URLs
 * Hide (undo) link if user isn't able to edit page
+* Invalidate cache of pages that includes images via redirects on upload
 
 === API changes in 1.13 ===
 
index 73b7ea5..6792b36 100644 (file)
@@ -3056,5 +3056,15 @@ class Title {
        public function isContentPage() {
                return MWNamespace::isContent( $this->getNamespace() );
        }
-       
+
+       public function getRedirectsHere() {
+               $redirs = array();
+               $dbr = wfGetDB( DB_SLAVE );
+               $result = $dbr->query( "SELECT page_title, page_namespace FROM page JOIN redirect ON page_id = rd_from WHERE rd_title = "
+                       . $dbr->addQuotes( $this->getDBKey() ) . " AND rd_namespace = " . $this->getNamespace(), __METHOD__ );
+               while( $row = $dbr->fetchObject( $result ) ) {
+                       $redirs[] = self::newFromRow( $row );
+               }
+               return $redirs;
+       }
 }
index f3afc74..123a242 100644 (file)
@@ -862,6 +862,12 @@ class LocalFile extends File
                # Invalidate cache for all pages using this file
                $update = new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' );
                $update->doUpdate();
+               # Invalidate cache for all pages that redirects on this page
+               $redirs = $this->getTitle()->getRedirectsHere();
+               foreach( $redirs as $redir ) {
+                       $update = new HTMLCacheUpdate( $redir, 'imagelinks' );
+                       $update->doUpdate();
+               }
 
                return true;
        }