/**
* 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
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 ) ) {