Merge "ImagePage: Inherit parent's handling for action=render"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 18 Oct 2018 15:34:41 +0000 (15:34 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 18 Oct 2018 15:34:41 +0000 (15:34 +0000)
RELEASE-NOTES-1.33
docs/hooks.txt
includes/api/ApiOptions.php
languages/i18n/en.json

index 59443df..00a6938 100644 (file)
@@ -34,6 +34,7 @@ production.
 * …
 
 === Action API changes in 1.33 ===
+* (T198913) Added 'ApiOptions' hook.
 * …
 
 === Action API internal changes in 1.33 ===
index fd7b300..90b2b05 100644 (file)
@@ -473,6 +473,15 @@ can alter or append to the array.
       (url), 'width', 'height', 'alt', 'align'.
     - url: Url for the given title.
 
+'ApiOptions': Called by action=options before applying changes to user
+preferences.
+$apiModule: Calling ApiOptions object
+$user: User object whose preferences are being changed
+$changes: Associative array of preference name => value
+$resetKinds: Array of strings specifying which options kinds to reset.
+  See User::resetOptions() and User::getOptionKinds() for possible
+  values.
+
 'ApiParseMakeOutputPage': Called when preparing the OutputPage object for
 ApiParse. This is mainly intended for calling OutputPage::addContentOverride()
 or OutputPage::addContentOverrideCallback().
index 3ea827c..c4de31f 100644 (file)
@@ -52,9 +52,9 @@ class ApiOptions extends ApiBase {
                        $this->dieWithError( [ 'apierror-missingparam', 'optionname' ] );
                }
 
-               if ( $params['reset'] ) {
-                       $this->resetPreferences( $params['resetkinds'] );
-                       $changed = true;
+               $resetKinds = $params['resetkinds'];
+               if ( !$params['reset'] ) {
+                       $resetKinds = [];
                }
 
                $changes = [];
@@ -68,6 +68,14 @@ class ApiOptions extends ApiBase {
                        $newValue = $params['optionvalue'] ?? null;
                        $changes[$params['optionname']] = $newValue;
                }
+
+               Hooks::run( 'ApiOptions', [ $this, $user, $changes, $resetKinds ] );
+
+               if ( $resetKinds ) {
+                       $this->resetPreferences( $resetKinds );
+                       $changed = true;
+               }
+
                if ( !$changed && !count( $changes ) ) {
                        $this->dieWithError( 'apierror-nochanges' );
                }
index 3ce047c..17b7d4c 100644 (file)
        "prefixindex-namespace": "All pages with prefix ($1 namespace)",
        "prefixindex-summary": "",
        "prefixindex-submit": "Show",
-       "prefixindex-strip": "Strip prefix in list",
+       "prefixindex-strip": "Hide the prefix in results",
        "shortpages": "Short pages",
        "shortpages-summary": "",
        "longpages": "Long pages",