resourceloader: Implement isKnownEmpty for user.options module
authorTimo Tijhof <krinklemail@gmail.com>
Mon, 18 Sep 2017 17:49:57 +0000 (18:49 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Mon, 18 Sep 2017 17:49:57 +0000 (18:49 +0100)
This allows ResourceLoaderClientHtml to output state=ready instead
of state=loading with a no-op mw.loader.implement() call being embedded.

Test Plan:
* View source on page view when logged-out.
* Before:
  - loader.state({"user.options":"loading"})
  - loader.implement("user.options@..",function(){ .. user.options.state([]) })
* After:
  - loader.state({"user.options":"ready"})

Bug: T176159
Change-Id: I18f76eaa960da9b0ca77f28e10f768587447a838

includes/resourceloader/ResourceLoaderUserOptionsModule.php

index 0c332cf..a15d310 100644 (file)
@@ -64,6 +64,14 @@ class ResourceLoaderUserOptionsModule extends ResourceLoaderModule {
                return false;
        }
 
+       /**
+        * @param ResourceLoaderContext $context
+        * @return bool
+        */
+       public function isKnownEmpty( ResourceLoaderContext $context ) {
+               return !$context->getUserObj()->getOptions( User::GETOPTIONS_EXCLUDE_DEFAULTS );
+       }
+
        /**
         * @return string
         */