(bug 37627) generic exception for not logged in users
authorAntoine Musso <hashar@free.fr>
Fri, 22 Jun 2012 10:37:47 +0000 (12:37 +0200)
committerAntoine Musso <hashar@free.fr>
Tue, 26 Jun 2012 14:03:42 +0000 (16:03 +0200)
commitb1c1448d98d5ed41ac9f650d9a569e22173e27fd
treefdd3dc1deefa227356e6369bee83692a695cf1f7
parentaf4b00448560583c979c90c79231d39f76917280
(bug 37627) generic exception for not logged in users

We have various place in MediaWiki core and in extensions which are
showing anonymous user a very standard error page about them not being
logged in. Each developer ends up writing its own because we do not
provide a generic error, that is what this patch does.

This UserNotLoggedIn exception, when called, will show the usual
ErrorPage with a default title and default reason text. That makes it as
easy to use as doing:

 if( $user->isAnon() ) {
  throw new UserNotLoggedIn();
 }

One can override the default reason by passing a message key as the
first parameter:

 if( $user->isAnon() ) {
  throw new UserNotLoggedIn( 'nologin-reason-text' );
 }

In that case, the page title will still be the default 'Not Logged In.'

Change-Id: Id81272995627bf0f5bbef785230a8e6e4e8582ca
RELEASE-NOTES-1.20
includes/Exception.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc