Add TitleQuickPermissions hook to Title::checkQuickPermissions
authorTyler Anthony Romeo <tylerromeo@gmail.com>
Fri, 8 Mar 2013 20:15:27 +0000 (15:15 -0500)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 24 May 2013 19:37:01 +0000 (19:37 +0000)
Currently Title permissions hooks get called after
Title::checkQuickPermissions, preventing users from
overriding quick permission checks. Added a hook to
allow this. Needed for bug 45898.

Change-Id: Id672270741282778815b06eff8b234ca4d819744

docs/hooks.txt
includes/Title.php

index a6fa9fe..f128efd 100644 (file)
@@ -2332,6 +2332,15 @@ database result.
 &$titleArray: set this to an object to override the default object returned
 $res: database result used to create the object
 
+'TitleQuickPermissions': Called from Title::checkQuickPermissions to add to
+or override the quick permissions check.
+$title: The Title object being accessed
+$user: The User performing the action
+$action: Action being performed
+&$errors: Array of errors
+$doExpensiveQueries: Whether to do expensive DB queries
+$short: Whether to return immediately on first error
+
 'TitleGetRestrictionTypes': Allows extensions to modify the types of protection
 that can be applied.
 $title: The title in question.
index 66a6ce5..29e810e 100644 (file)
@@ -1739,6 +1739,10 @@ class Title {
         * @return Array list of errors
         */
        private function checkQuickPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) {
+               if ( !wfRunHooks( 'TitleQuickPermissions', array( $this, $user, $action, &$errors, $doExpensiveQueries, $short ) ) ) {
+                       return $errors;
+               }
+
                if ( $action == 'create' ) {
                        if (
                                ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) ||