Consistent behavior of read-only reason
authorFlorian Schmidt <florian.schmidt.stargatewissen@gmail.com>
Sat, 19 Aug 2017 16:21:40 +0000 (18:21 +0200)
committerFlorian Schmidt <florian.schmidt.stargatewissen@gmail.com>
Mon, 28 Aug 2017 15:51:17 +0000 (17:51 +0200)
commit38fce189c441a075172eef516f25e81b8d1a5ada
treeecbdab575c2516bf1f56243949c464ed1824e634
parent38999cc27a5b38050472532635027802c13a1d90
Consistent behavior of read-only reason

Before this commit, the reason set in the global $wgReadOnly was differently handled
on different special pages. While on most of them, like Special:Upload, the reason
is allowed to have HTML, which can be used in Wikitext, too, Special:CreateAccount
always outputted an escaped version of this reason.

Most special pages uses the ReadOnlyError exception to print a read-only error,
however, AuthManager uses Status objects to communicate between the backend and the
frontend. Therefore the same message and parameters were wrapped in a Status object
and, in the frontend, directly passed to the constructor of ErrorPageError. Unfortunately,
Status::getMessage() escapes the parameters of a message, which is the reason, why the
wiki is read-only. To bypass this restriction, AuthManager now creates a Message object
directly, does not escape the reason, and uses the resulting object to create a Status
object from.

Now the reason is not escaped on Special:CreateAccount anymore, like on most other
special pages.

The read-only message on the protection form is, also before this commit, not escaped and
already displayed correctly, as the read-only is checked in the constructor of the
protection form already and, if the Wiki is read only, handled as a permission error and
already displayed correctly. This commit fixes the behavior of WikiPage in case of it's used
somewhere else, subclassed or if the check in the frontend will be removed and the Status of
WikiPage will be used.

Bug: T157036
Change-Id: Idbfe556fcb90f8bda8fae9d728ca9dee5ea02f67
includes/auth/AuthManager.php
includes/page/WikiPage.php
tests/phpunit/includes/auth/AuthManagerTest.php