*/
use MediaWiki\Linker\LinkTarget;
+use Wikimedia\Assert\Assert;
use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\IDatabase;
+use MediaWiki\MediaWikiServices;
/**
* Abstraction for ResourceLoader modules which pull from wiki pages
protected $group;
/**
- * @param array $options For back-compat, this can be omitted in favour of overwriting getPages.
+ * @param array|null $options For back-compat, this can be omitted in favour of overwriting
+ * getPages.
*/
public function __construct( array $options = null ) {
if ( is_null( $options ) ) {
if ( $options['type'] !== 'style' ) {
continue;
}
- $media = isset( $options['media'] ) ? $options['media'] : 'all';
+ $media = $options['media'] ?? 'all';
$style = $this->getContent( $titleText, $context );
if ( strval( $style ) === '' ) {
continue;
$func = [ static::class, 'fetchTitleInfo' ];
$fname = __METHOD__;
- $cache = ObjectCache::getMainWANInstance();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$allInfo = $cache->getWithSetCallback(
$cache->makeGlobalKey( 'resourceloader', 'titleinfo', $db->getDomainID(), $hash ),
$cache::TTL_HOUR,
* @param Title $title
* @param Revision|null $old Prior page revision
* @param Revision|null $new New page revision
- * @param string $wikiId
+ * @param string $domain Database domain ID
* @since 1.28
*/
public static function invalidateModuleCache(
- Title $title, Revision $old = null, Revision $new = null, $wikiId
+ Title $title, Revision $old = null, Revision $new = null, $domain
) {
static $formats = [ CONTENT_FORMAT_CSS, CONTENT_FORMAT_JAVASCRIPT ];
+ Assert::parameterType( 'string', $domain, '$domain' );
+
+ // TODO: MCR: differentiate between page functionality and content model!
+ // Not all pages containing CSS or JS have to be modules! [PageType]
if ( $old && in_array( $old->getContentFormat(), $formats ) ) {
$purge = true;
} elseif ( $new && in_array( $new->getContentFormat(), $formats ) ) {
}
if ( $purge ) {
- $cache = ObjectCache::getMainWANInstance();
- $key = $cache->makeGlobalKey( 'resourceloader', 'titleinfo', $wikiId );
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ $key = $cache->makeGlobalKey( 'resourceloader', 'titleinfo', $domain );
$cache->touchCheckKey( $key );
}
}