Merge "New hook ApiCheckCanExecute."
authorDaniel Kinzler <daniel.kinzler@wikimedia.de>
Wed, 5 Sep 2012 19:06:48 +0000 (19:06 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 5 Sep 2012 19:06:48 +0000 (19:06 +0000)
docs/hooks.txt
includes/api/ApiMain.php

index 7844aaf..5b78ed9 100644 (file)
@@ -314,6 +314,13 @@ $body: Body of the message
 Use this to extend core API modules.
 &$module: Module object
 
+'APICheckCanExecute': Called during ApiMain::checkCanExecute. Use to
+further authenticate and authorize API clients before executing the
+module. Return false and set a message to cancel the request.
+$module: Module object
+$user: Current user
+&$message: API usage message to die with
+
 'APIEditBeforeSave': before saving a page with api.php?action=edit,
 after processing request parameters. Return false to let the request
 fail, returning an error message or an <edit result="Failure"> tag
index 2a94a65..35febd9 100644 (file)
@@ -761,6 +761,12 @@ class ApiMain extends ApiBase {
                                $this->dieReadOnly();
                        }
                }
+
+               // Allow extensions to stop execution for arbitrary reasons.
+               $message = false;
+               if( !wfRunHooks( 'ApiCheckCanExecute', array( $module, $user, &$message ) ) ) {
+                       $this->dieUsageMsg( $message );
+               }
        }
 
        /**