Merge "Add CollationFa"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderWikiModule.php
index 9c3b41c..14d6e05 100644 (file)
@@ -36,7 +36,6 @@
  * Safe for calls on local wikis are:
  * - Option getters:
  *   - getGroup()
- *   - getPosition()
  *   - getPages()
  * - Basic methods that strictly involve the foreign database
  *   - getDB()
@@ -44,8 +43,6 @@
  *   - getTitleInfo()
  */
 class ResourceLoaderWikiModule extends ResourceLoaderModule {
-       /** @var string Position on the page to load this module at */
-       protected $position = 'bottom';
 
        // Origin defaults to users with sitewide authority
        protected $origin = self::ORIGIN_USER_SITEWIDE;
@@ -72,7 +69,6 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
 
                foreach ( $options as $member => $option ) {
                        switch ( $member ) {
-                               case 'position':
                                case 'styles':
                                case 'scripts':
                                case 'group':
@@ -162,11 +158,12 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
                        return null;
                }
 
-               $revision = Revision::newFromTitle( $title, false, Revision::READ_NORMAL );
+               $revision = Revision::newKnownCurrent( wfGetDB( DB_REPLICA ), $title->getArticleID(),
+                       $title->getLatestRevID() );
                if ( !$revision ) {
                        return null;
                }
-
+               $revision->setTitle( $title );
                $content = $revision->getContent( Revision::RAW );
 
                if ( !$content ) {
@@ -360,21 +357,22 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
                        }
                }
 
-               $allPageNames = array_keys( $allPages );
-               sort( $allPageNames );
-               $hash = sha1( implode( '|', $allPageNames ) );
+               $pageNames = array_keys( $allPages );
+               sort( $pageNames );
+               $hash = sha1( implode( '|', $pageNames ) );
 
                // Avoid Zend bug where "static::" does not apply LSB in the closure
                $func = [ static::class, 'fetchTitleInfo' ];
+               $fname = __METHOD__;
 
                $cache = ObjectCache::getMainWANInstance();
                $allInfo = $cache->getWithSetCallback(
                        $cache->makeGlobalKey( 'resourceloader', 'titleinfo', $db->getWikiID(), $hash ),
                        $cache::TTL_HOUR,
-                       function ( $curValue, &$ttl, array &$setOpts ) use ( $func, $allPageNames, $db ) {
+                       function ( $curVal, &$ttl, array &$setOpts ) use ( $func, $pageNames, $db, $fname ) {
                                $setOpts += Database::getCacheSetOptions( $db );
 
-                               return call_user_func( $func, $db, $allPageNames, __METHOD__ );
+                               return call_user_func( $func, $db, $pageNames, $fname );
                        },
                        [ 'checkKeys' => [ $cache->makeGlobalKey( 'resourceloader', 'titleinfo', $db->getWikiID() ) ] ]
                );
@@ -433,13 +431,6 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
                }
        }
 
-       /**
-        * @return string
-        */
-       public function getPosition() {
-               return $this->position;
-       }
-
        /**
         * @since 1.28
         * @return string