r76437 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76436‎ | r76437 | r76438 >
Date:09:16, 10 November 2010
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* (bug 19944) Link on image thumbnails no longer link to "Media:" namespace in some cases
* (bug 25670) wfFindFile() now checks the namespace of the given title, only "File" and "Media" are allowed now

The problem with bug 19944 was that the cache in RepoGroup was holding a file with a Title that has its namespace set to NS_MEDIA; the cache is now only used for title with namespace set to NS_FILE.
Also modified ImageGallery to not call wfFindFile() on non-NS_FILE title; was obviously breaking the above fix.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/ImageGallery.php (modified) (history)
  • /trunk/phase3/includes/filerepo/RepoGroup.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/RepoGroup.php
@@ -100,10 +100,15 @@
101101 }
102102 }
103103
 104+ if ( $title->getNamespace() != NS_MEDIA && $title->getNamespace() != NS_FILE ) {
 105+ throw new MWException( __METHOD__ . ' recieved an Title object with incorrect namespace' );
 106+ }
 107+
104108 # Check the cache
105109 if ( empty( $options['ignoreRedirect'] )
106110 && empty( $options['private'] )
107 - && empty( $options['bypassCache'] ) )
 111+ && empty( $options['bypassCache'] )
 112+ && $title->getNamespace() == NS_FILE )
108113 {
109114 $useCache = true;
110115 $time = isset( $options['time'] ) ? $options['time'] : '';
Index: trunk/phase3/includes/ImageGallery.php
@@ -244,9 +244,13 @@
245245 $time = $descQuery = false;
246246 wfRunHooks( 'BeforeGalleryFindFile', array( &$this, &$nt, &$time, &$descQuery ) );
247247
248 - $img = wfFindFile( $nt, array( 'time' => $time ) );
 248+ if ( $nt->getNamespace() == NS_FILE ) {
 249+ $img = wfFindFile( $nt, array( 'time' => $time ) );
 250+ } else {
 251+ $img = false;
 252+ }
249253
250 - if( $nt->getNamespace() != NS_FILE || !$img ) {
 254+ if( !$img ) {
251255 # We're dealing with a non-image, spit out the name and be done with it.
252256 $thumbhtml = "\n\t\t\t".'<div style="height: '.($this->mHeights*1.25+2).'px;">'
253257 . htmlspecialchars( $nt->getText() ) . '</div>';
Index: trunk/phase3/RELEASE-NOTES
@@ -416,6 +416,10 @@
417417 * (bug 17789) Added a note to the total views on Special:Statistics saying that
418418 is doesn't count non-existing pages and special pages
419419 * (bug 17996) HTTP redirects are now combined when requesting a special page
 420+* (bug 19944) Link on image thumbnails no longer link to "Media:" namespace in
 421+ some cases
 422+* (bug 25670) wfFindFile() now checks the namespace of the given title, only
 423+ "File" and "Media" are allowed now
420424
421425 === API changes in 1.17 ===
422426 * (bug 22738) Allow filtering by action type on query=logevent.

Comments

#Comment by Bryan (talk | contribs)   23:21, 7 January 2011

I'd prefer to fix this by including the namespace in the cache key, but ok.

Status & tagging log