diff options
author | Bartosz Dziewoński <dziewonski@fastmail.fm> | 2024-06-07 01:50:00 +0200 |
---|---|---|
committer | Bartosz Dziewoński <dziewonski@fastmail.fm> | 2024-06-12 00:07:02 +0200 |
commit | 4108bbe1afad86a73fbc0b307b20e4c7a2c459fb (patch) | |
tree | 7bf129dab793e173af335dc722b5eb822be50bd4 /maintenance/createBotPassword.php | |
parent | 11accb12e77211928e821e57951843ee248b909d (diff) | |
download | mediawikicore-4108bbe1afad86a73fbc0b307b20e4c7a2c459fb.tar.gz mediawikicore-4108bbe1afad86a73fbc0b307b20e4c7a2c459fb.zip |
Maintenance: Print errors from StatusValue objects in a consistent way
Allow Maintenance::error() and Maintenance::fatalError() to take
StatusValue objects. They now print each error message from the
status on a separate line, in English, ignoring on-wiki message
overrides, as wikitext but after parser function expansion.
Thoughts on the previously commonly used methods:
- $status->getMessage( false, false, 'en' )->text()
Almost the same as the new output, but it allows on-wiki message
overrides, and if there is more than one error, it prefixes each
line with a '*' (like a wikitext list).
- $status->getMessage( false, false, 'en' )->plain()
- $status->getWikiText( false, false, 'en' )
As above, but these forms do not expand parser functions
such as {{GENDER:}}.
- print_r( $status->getErrorsArray(), true )
- print_r( $status->getErrors(), true )
These forms output the message keys instead of the message text,
which is not very human-readable.
The error messages are now always printed using error() rather
than output(), which means they go to STDERR rather than STDOUT
and they're printed even with the --quiet flag.
Change-Id: I5b8e7c7ed2a896a1029f58857a478d3f1b4b0589
Diffstat (limited to 'maintenance/createBotPassword.php')
-rw-r--r-- | maintenance/createBotPassword.php | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/maintenance/createBotPassword.php b/maintenance/createBotPassword.php index ef77a3e33e1e..1655ddd625aa 100644 --- a/maintenance/createBotPassword.php +++ b/maintenance/createBotPassword.php @@ -128,10 +128,8 @@ class CreateBotPassword extends Maintenance { $this->output( "Success.\n" ); $this->output( "Log in using username:'{$username}@{$appId}' and password:'{$password}'.\n" ); } else { - $this->fatalError( - "Bot password creation failed. Does this appid already exist for the user perhaps?\n\nErrors:\n" . - print_r( $status->getErrors(), true ) - ); + $this->error( "Bot password creation failed. Does this appid already exist for the user perhaps?" ); + $this->fatalError( $status ); } } |