From ba220d501da7bc8df2b544e2c0e04ab78d02e804 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Sun, 16 Jan 2011 00:43:56 +0000 Subject: [PATCH] (bug 2585) Image pages should send 404 if no image, no shared image and no description page (To be consistant with how non-existant article pages act). --- RELEASE-NOTES | 2 ++ includes/ImagePage.php | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 10b74958da..bd8c551348 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -82,6 +82,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 26733) Wrap initial table creation in transaction * (bug 26729) Category pages should return 404 if they do not exist and have no members. +* (bug 2585) Image pages should send 404 if no image, no shared image and no + description page. === API changes in 1.18 === * (bug 26339) Throw warning when truncating an overlarge API result diff --git a/includes/ImagePage.php b/includes/ImagePage.php index bf903b760b..d00120f507 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -498,8 +498,16 @@ EOT { $nofile = 'filepage-nofile'; } + // Note, if there is an image description page, but + // no image, then this setRobotPolicy is overriden + // by Article::View(). $wgOut->setRobotPolicy( 'noindex,nofollow' ); $wgOut->wrapWikiMsg( "", $nofile ); + if ( !$this->getID() ) { + // If there is no image, no shared image, and no description page, + // output a 404, to be consistent with articles. + $wgRequest->response()->header( "HTTP/1.x 404 Not Found" ); + } } } -- 2.20.1