Page MenuHomePhabricator

Consider omitting badaccess-group0 in some cases
Closed, ResolvedPublic

Description

MediaWiki sometimes produces the following error message:

You do not have permission to <do something>, for the following reason:

You are not allowed to execute the action you have requested.

It seems like the second line of this, as well as "for the following reason:" are useless here - the second line isn't a reason. The error message should just be:

You do not have permission to <do something>

Details

Event Timeline

Change #1222751 had a related patch set uploaded (by Pppery; author: Pppery):

[mediawiki/core@master] Clean up some edge cases in displaying permission errors

https://gerrit.wikimedia.org/r/1222751

It seems like the second line of this, as well as "for the following reason:" are useless here

I doubt if this premise is correct. It seems you're not sure either.

the second line isn't a reason

How do you decide 'a reason' and 'not a reason'? Probably you disagree with the reason... and then you conclude it's 'not a reason'

To be honest, it has also struck me (before @Pppery filed this task) that the current wording kinda reads like "you're not allowed to do this, because you're not allowed to do this".

Something is a reason if it, well, explains why you're not allowed to do it.

"You are not allowed to execute the action you have requested" just isn't. It explains nothing.

On the other hand "The action you have requested is limited to users in the groups <groups>" does explain; it says you need to be in certain groups.

I agree with @Pppery that the second line could be omitted. I reviewed some uses of the relevant localisation message 'badaccess-group0', and it's mostly used when we actually don't know why the user isn't allowed to perform the action (e.g. because the action was prevented by an extension and it did not specify the reason). Sometimes it's used because a developer didn't bother to write a custom error message for some uncommon situation, but in that case it doesn't really explain anything, either (and ideally it would be replaced by a better message).

At first I thought that this message is used when the reason is that you don't belong to any groups that have the necessary right, but that is not the case – we have the 'badaccess-groups' message for that situation (which lists the groups that have the right).

It might make sense to have two messages for these two cases:

  • Something like "You are not allowed to do this." to be used by the lazy developers in their permission checks – MediaWiki could omit this message, or replace it with "Please log in ..." if it can figure out what action was attempted and that logging in would allow you to perform it
  • Something like "You are not allowed to do this for unknown reason." to be used when the reason isn't known due to technical limitations, like an action prevented by an extension, or e.g. data integrity issues making it unclear what actions are allowed. This message being shown would generally indicate a bug or at least a possible improvement somewhere in the software.

But that's just a vague idea, I'm not planning to work on that, nor suggesting you should.

There's also another use of badaccess-group0, where the error is coming from MediaWiki core when no groups have the necessary right, like https://en.wikipedia.org/wiki/Special:LockDB

(But you can't just say "nobody can do this" because some extension hook could be granting the user permissions in odd circumstances. I think MediaWiki-extensions-Translate's TranslationSandbox works this way, although they just redirect to the homepage if someone who isn't sandboxed tries to go to the pages for those who are)

And a third for "we know why you can't do this, but deliberately aren't telling you for security reasons": seen at https://github.com/wikimedia/mediawiki/blob/master/includes/FileRepo/AuthenticatedFileEntryPoint.php#L201 or in code at https://office.wikimedia.org/w/img_auth.php (if you're not logged on to officewiki)

Change #1222751 merged by jenkins-bot:

[mediawiki/core@master] Clean up some edge cases in displaying permission errors

https://gerrit.wikimedia.org/r/1222751