From ebee381c23403f1d3b2e2bc40df979edcb30bab2 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 24 Sep 2019 00:33:20 +0100 Subject: [PATCH] exception: Add missing early return for UserNotLoggedIn error page Follows-up d0439af89f6b254c. If the UserNotLoggedIn class is constructed with an unsupported message parameter, thrown, and handled by MWExceptionHandler, the report() method would get called, and it would call the parent, which stages a full error page and sends it via OutputPage::output. Due to the missing return statement, it would then still execute the remaining code, which messes up the internal state of the already-sent OutputPage object by changing its redirect target (which will never be used, but might confuse other consumers), and trying to re-send output() and redirect headers, which will fail with a warning. Fixing this is required for T233594 and Iaeaf5e55a586, which allows ErrorPageError to be "stage only" without ending output. Without this fix, it would call the parent and do stage-only, but then the remaining code in this method also work and actually succeed at sending an invalid message to the user. To preserve current (accidentally correct) behaviour, this needs to be fixed first. Bug: T233594 Bug: T17484 Change-Id: Ic5d73becd889839399a5b425cbbe22a3401acea9 --- includes/exception/UserNotLoggedIn.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/exception/UserNotLoggedIn.php b/includes/exception/UserNotLoggedIn.php index 7a99765e9c..246c944f2e 100644 --- a/includes/exception/UserNotLoggedIn.php +++ b/includes/exception/UserNotLoggedIn.php @@ -80,9 +80,10 @@ class UserNotLoggedIn extends ErrorPageError { // since the message may not be compatible. if ( !in_array( $this->msg, LoginHelper::getValidErrorMessages() ) ) { parent::report(); + return; } - // Message is valid. Redirec to Special:Userlogin + // Message is valid. Redirect to Special:Userlogin $context = RequestContext::getMain(); -- 2.20.1