From: Gergő Tisza Date: Fri, 14 Oct 2016 22:59:11 +0000 (+0000) Subject: Relax phpdoc of PermissionError to match actual usage X-Git-Tag: 1.31.0-rc.0~5059^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/supprimer.php?a=commitdiff_plain;h=d452323171833903331814cdf53134598fe71aed;p=lhc%2Fweb%2Fwiklou.git Relax phpdoc of PermissionError to match actual usage Also fix OutputPage::showPermissionsErrorPage to handle everything it claims to handle. Change-Id: I8ed4a6f2f038fe70084ab673300e24af97e935db --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index a69c0e6692..6527a0dbd0 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2390,10 +2390,14 @@ class OutputPage extends ContextSource { /** * Output a standard permission error page * - * @param array $errors Error message keys + * @param array $errors Error message keys or [key, param...] arrays * @param string $action Action that was denied or null if unknown */ public function showPermissionsErrorPage( array $errors, $action = null ) { + foreach ( $errors as $key => $error ) { + $errors[$key] = (array)$error; + } + // For some action (read, edit, create and upload), display a "login to do this action" // error if all of the following conditions are met: // 1. the user is not logged in diff --git a/includes/exception/PermissionsError.php b/includes/exception/PermissionsError.php index bd0b1204d4..e31374c2c7 100644 --- a/includes/exception/PermissionsError.php +++ b/includes/exception/PermissionsError.php @@ -29,12 +29,19 @@ class PermissionsError extends ErrorPageError { public $permission, $errors; /** - * @param string $permission A permission name. - * @param string[] $errors Error message keys + * @param string|null $permission A permission name or null if unknown + * @param array $errors Error message keys or [key, param...] arrays; must not be empty if + * $permission is null + * @throws \InvalidArgumentException */ public function __construct( $permission, $errors = [] ) { global $wgLang; + if ( $permission === null && !$errors ) { + throw new \InvalidArgumentException( __METHOD__ . + ': $permission and $errors cannot both be empty' ); + } + $this->permission = $permission; if ( !count( $errors ) ) {