From: Victor Vasiliev Date: Sat, 12 Apr 2008 18:06:57 +0000 (+0000) Subject: * Invalidate cache of pages that includes images via redirects on upload X-Git-Tag: 1.31.0-rc.0~48409 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=ffe44db3e3d89aac066be104fca2cc74fdac4cb3;p=lhc%2Fweb%2Fwiklou.git * Invalidate cache of pages that includes images via redirects on upload --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 779ecc8d86..8b35a6ca8f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/Title.php b/includes/Title.php index 73b7ea53fb..6792b3638f 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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; + } } diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index f3afc74205..123a242d94 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -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; }