From b72368d65a71dabd648b71862dd44dcc7c4b0940 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Wed, 2 Jan 2008 02:49:31 +0000 Subject: [PATCH] When a user is prohibited from creating a page, a title of "View source" makes no sense, and there should be no "Return to [[Page]]" link. --- RELEASE-NOTES | 2 ++ includes/EditPage.php | 3 +-- includes/OutputPage.php | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 9ab08d1dfe..f2ca88a1cb 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -112,6 +112,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Add HTML ID's mw-read-only-warning and mw-anon-edit-warning to warnings when editing to allow CSS styling. * Parser now returns list of sections +* When a user is prohibited from creating a page, a title of "View source" + makes no sense, and there should be no "Return to [[Page]]" link. === Bug fixes in 1.12 === diff --git a/includes/EditPage.php b/includes/EditPage.php index ab4b86a362..8fa5417048 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -389,8 +389,7 @@ class EditPage { # array_diff returns elements in $permErrors that are not in $remove. $permErrors = array_diff( $permErrors, $remove ); - if ( !empty($permErrors) ) - { + if ( !empty($permErrors) ) { wfDebug( "$fname: User can't edit\n" ); $wgOut->readOnlyPage( $this->getContent(), true, $permErrors ); wfProfileOut( $fname ); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 3ce9451617..6e50960ab6 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1037,8 +1037,12 @@ class OutputPage { if ( !empty($reasons) ) { // Permissions error - $this->setPageTitle( wfMsg( 'viewsource' ) ); - $this->setSubtitle( wfMsg( 'viewsourcefor', $skin->makeKnownLinkObj( $wgTitle ) ) ); + if( $source ) { + $this->setPageTitle( wfMsg( 'viewsource' ) ); + $this->setSubtitle( wfMsg( 'viewsourcefor', $skin->makeKnownLinkObj( $wgTitle ) ) ); + } else { + $this->setPageTitle( wfMsg( 'badaccess' ) ); + } $this->addWikiText( $this->formatPermissionsErrorMessage( $reasons ) ); } else { // Wiki is read only @@ -1071,7 +1075,12 @@ class OutputPage { $this->addHTML( $skin->formatTemplates( $article->getUsedTemplates() ) ); } - $this->returnToMain( false, $wgTitle ); + # If the title doesn't exist, it's fairly pointless to print a return + # link to it. After all, you just tried editing it and couldn't, so + # what's there to do there? + if( $wgTitle->exists() ) { + $this->returnToMain( false, $wgTitle ); + } } /** @deprecated */ -- 2.20.1