From 61a8610ddce698c3bca3931602d92b43ed6bdc43 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Wed, 10 Nov 2010 09:16:28 +0000 Subject: [PATCH] * (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. --- RELEASE-NOTES | 4 ++++ includes/ImageGallery.php | 8 ++++++-- includes/filerepo/RepoGroup.php | 7 ++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7dc2623173..d0da78f4aa 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -416,6 +416,10 @@ LocalSettings.php. The specific bugs are listed below in the general notes. * (bug 17789) Added a note to the total views on Special:Statistics saying that is doesn't count non-existing pages and special pages * (bug 17996) HTTP redirects are now combined when requesting a special page +* (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 === API changes in 1.17 === * (bug 22738) Allow filtering by action type on query=logevent. diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index 3e6e3b94f7..281cac2df4 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -244,9 +244,13 @@ class ImageGallery $time = $descQuery = false; wfRunHooks( 'BeforeGalleryFindFile', array( &$this, &$nt, &$time, &$descQuery ) ); - $img = wfFindFile( $nt, array( 'time' => $time ) ); + if ( $nt->getNamespace() == NS_FILE ) { + $img = wfFindFile( $nt, array( 'time' => $time ) ); + } else { + $img = false; + } - if( $nt->getNamespace() != NS_FILE || !$img ) { + if( !$img ) { # We're dealing with a non-image, spit out the name and be done with it. $thumbhtml = "\n\t\t\t".'
' . htmlspecialchars( $nt->getText() ) . '
'; diff --git a/includes/filerepo/RepoGroup.php b/includes/filerepo/RepoGroup.php index 82f79390e8..b9996941b1 100644 --- a/includes/filerepo/RepoGroup.php +++ b/includes/filerepo/RepoGroup.php @@ -100,10 +100,15 @@ class RepoGroup { } } + if ( $title->getNamespace() != NS_MEDIA && $title->getNamespace() != NS_FILE ) { + throw new MWException( __METHOD__ . ' recieved an Title object with incorrect namespace' ); + } + # Check the cache if ( empty( $options['ignoreRedirect'] ) && empty( $options['private'] ) - && empty( $options['bypassCache'] ) ) + && empty( $options['bypassCache'] ) + && $title->getNamespace() == NS_FILE ) { $useCache = true; $time = isset( $options['time'] ) ? $options['time'] : ''; -- 2.20.1