From cbed68b994cc587b7e5b8e5b2f93447a9464c8b5 Mon Sep 17 00:00:00 2001 From: madman Date: Thu, 6 Sep 2012 03:17:41 +0000 Subject: [PATCH] (bug 39688) action=info displays misleading edit history for redlinks * Will not display edit history and properties for nonexistent pages * Will not display misleading page information for noncurrent revisions Change-Id: I23dd6ead555449d0810cbc64d79737654818e3e6 --- includes/actions/InfoAction.php | 20 ++++++++++++++++++++ languages/messages/MessagesEn.php | 1 + languages/messages/MessagesQqq.php | 1 + maintenance/language/messages.inc | 1 + 4 files changed, 23 insertions(+) diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index b573b1addf..3adf89080a 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -58,6 +58,22 @@ class InfoAction extends FormlessAction { public function onView() { $content = ''; + // Validate revision + $oldid = $this->page->getOldID(); + if ( $oldid ) { + $revision = $this->page->getRevisionFetched(); + + // Revision is missing + if ( $revision === null ) { + return $this->msg( 'missing-revision', $oldid )->parse(); + } + + // Revision is not current + if ( !$revision->isCurrent() ) { + return $this->msg( 'pageinfo-not-current' )->plain(); + } + } + // Page header if ( !$this->msg( 'pageinfo-header' )->isDisabled() ) { $content .= $this->msg( 'pageinfo-header' )->parse(); @@ -281,6 +297,10 @@ class InfoAction extends FormlessAction { ); } + if ( !$this->page->exists() ) { + return $pageInfo; + } + // Edit history $pageInfo['header-edits'] = array(); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index f5353b6906..c0e80307c8 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -3737,6 +3737,7 @@ This is probably caused by a link to a blacklisted external site.', # Info page 'pageinfo-header' => '-', # do not translate or duplicate this message to other languages 'pageinfo-title' => 'Information for "$1"', +'pageinfo-not-current' => 'Information may only be displayed for the current revision.', 'pageinfo-header-basic' => 'Basic information', 'pageinfo-header-edits' => 'Edit history', 'pageinfo-header-restrictions' => 'Page protection', diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index 180538f269..981bd818ba 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -3511,6 +3511,7 @@ See also {{msg-mw|Anonuser}} and {{msg-mw|Siteusers}}.', # Info page 'pageinfo-title' => 'Page title for action=info. Parameters: * $1 is the page name', +'pageinfo-not-current' => 'Error message displayed when information for an old revision is requested.', 'pageinfo-header-basic' => 'Table section header in action=info.', 'pageinfo-header-edits' => 'Table section header in action=info.', 'pageinfo-header-restrictions' => 'Table section header in action=info.', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 45b24c4971..2980e66158 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2673,6 +2673,7 @@ $wgMessageStructure = array( 'info' => array( 'pageinfo-header', 'pageinfo-title', + 'pageinfo-not-current', 'pageinfo-header-basic', 'pageinfo-header-edits', 'pageinfo-header-restrictions', -- 2.20.1