mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-23 16:06:53 +00:00
Merge "Fix static cache access"
This commit is contained in:
commit
81433b0973
|
@ -92,18 +92,22 @@ class HookUtils {
|
|||
*/
|
||||
public static function hasPagePropCached( Title $title, string $prop ): bool {
|
||||
Assert::parameter(
|
||||
in_array( $prop, static::CACHED_PAGE_PROPS, true ),
|
||||
in_array( $prop, self::CACHED_PAGE_PROPS, true ),
|
||||
'$prop',
|
||||
'must be one of the cached properties'
|
||||
);
|
||||
$id = $title->getArticleId();
|
||||
if ( !isset( static::$propCache[ $id ] ) ) {
|
||||
if ( !isset( self::$propCache[ $id ] ) ) {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
// Always fetch all of our properties, we need to check several of them on most requests
|
||||
static::$propCache +=
|
||||
$services->getPageProps()->getProperties( $title, static::CACHED_PAGE_PROPS );
|
||||
$pagePropsPerId = $services->getPageProps()->getProperties( $title, self::CACHED_PAGE_PROPS );
|
||||
if ( $pagePropsPerId ) {
|
||||
self::$propCache += $pagePropsPerId;
|
||||
} else {
|
||||
self::$propCache[ $id ] = [];
|
||||
}
|
||||
}
|
||||
return isset( static::$propCache[ $id ][ $prop ] );
|
||||
return isset( self::$propCache[ $id ][ $prop ] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue