Manual:Hooks/getUserPermissionsErrorsExpensive

From Linux Web Expert

getUserPermissionsErrorsExpensive
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>
Same as getUserPermissionsErrors as but called only if expensive checks are enabled
<translate> Define function:</translate>
public static function ongetUserPermissionsErrorsExpensive( $title, $user, $action, &$result ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"getUserPermissionsErrorsExpensive": "MediaWiki\\Extension\\MyExtension\\Hooks::ongetUserPermissionsErrorsExpensive"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> Permissions/PermissionManager.php
<translate> Interface:</translate> getUserPermissionsErrorsExpensiveHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:getUserPermissionsErrorsExpensive extensions</tvar>.</translate>

Details

  • $title: Title object being checked against
  • $user : Current user object
  • $action: Action being checked
  • &$result: User permissions error to add, in a format understood by PermissionManager::resultToError() like [ 'error-message-name', $parameter ]. If none, return true. Otherwise, the error message is passed all the way to PermissionManager::userCan() and then used in whatever way the calling code wants.

Differences from getUserPermissionsErrors

Both hooks are typically run when checking for proper permissions in Title.php . When it is desireable to skip potentially expensive cascading permission checks, only getUserPermissionsErrors is run. This behavior is suitable for nonessential UI controls in common cases, but not for functional access control. This behavior may provide false positives, but should never provide a false negative.