r45314 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45313‎ | r45314 | r45315 >
Date:11:36, 2 January 2009
Author:aaron
Status:resolved (Comments)
Tags:
Comment:
(bug 9243) Avoid exit to make MW handle page exceptions properly
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/includes/diff/DifferenceEngine.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/diff/DifferenceEngine.php
@@ -148,11 +148,11 @@
149149 $wgOut->setSubtitle( wfMsgExt( 'difference', array( 'parseinline' ) ) );
150150 $wgOut->setRobotPolicy( 'noindex,nofollow' );
151151
152 - if ( !( $this->mOldPage->userCanRead() && $this->mNewPage->userCanRead() ) ) {
 152+ if ( !$this->mOldPage->userCanRead() || !$this->mNewPage->userCanRead() ) {
153153 $wgOut->loginToUse();
154154 $wgOut->output();
155155 wfProfileOut( __METHOD__ );
156 - exit;
 156+ throw new MWException("Permission Error: you do not have access to view this page");
157157 }
158158
159159 $sk = $wgUser->getSkin();
@@ -423,11 +423,11 @@
424424
425425 # Check if user is allowed to look at this page. If not, bail out.
426426 #
427 - if ( !( $this->mTitle->userCanRead() ) ) {
 427+ if ( !$this->mTitle->userCanRead() ) {
428428 $wgOut->loginToUse();
429429 $wgOut->output();
430430 wfProfileOut( __METHOD__ );
431 - exit;
 431+ throw new MWException("Permission Error: you do not have access to view this page");
432432 }
433433
434434 # Prepare the header box
Index: trunk/phase3/includes/Article.php
@@ -847,7 +847,7 @@
848848 $wgOut->loginToUse();
849849 $wgOut->output();
850850 wfProfileOut( __METHOD__ );
851 - exit;
 851+ throw new MWException("Permission Error: you do not have access to view this page");
852852 }
853853
854854 # We're looking at an old revision
Index: trunk/phase3/includes/Wiki.php
@@ -145,7 +145,7 @@
146146 if( !is_null( $title ) && !$title->userCanRead() ) {
147147 $output->loginToUse();
148148 $output->output();
149 - exit;
 149+ throw new MWException("Permission Error: you do not have access to view this page");
150150 }
151151 }
152152

Follow-up revisions

RevisionCommit summaryAuthorDate
r45320Tweak r45314: just return outaaron15:56, 2 January 2009

Comments

#Comment by IAlex (talk | contribs)   14:51, 2 January 2009

This breaks output: the page is outputed twice, first time for the "normal" error page (like before) and a second time for the exception.

#Comment by Brion VIBBER (talk | contribs)   22:14, 6 January 2009

Changed a bunch in r45320

Status & tagging log