Fix deleting cache and add type hinting to hooks

This commit is contained in:
Luqgreg 2018-08-18 18:12:16 +02:00
parent 49c6d8a5b5
commit e51204ff8b

View file

@ -2,26 +2,24 @@
class PortableInfoboxHooks {
public static function onWgQueryPages( &$queryPages = [] ) {
public static function onWgQueryPages( array &$queryPages = [] ) {
$queryPages[] = [ 'AllinfoboxesQueryPage', 'AllInfoboxes' ];
return true;
}
public static function onBeforeParserrenderImageGallery( $parser, $gallery ) {
if ( $gallery instanceof ImageGalleryBase ) {
PortableInfobox\Helpers\PortableInfoboxDataBag::getInstance()->setGallery(
Parser::MARKER_PREFIX . "-gallery-" . sprintf( '%08X', $parser->mMarkerIndex - 1 ) . Parser::MARKER_SUFFIX,
$gallery
);
}
public static function onBeforeParserrenderImageGallery( Parser &$parser, ImageGalleryBase &$gallery ) {
PortableInfobox\Helpers\PortableInfoboxDataBag::getInstance()->setGallery(
Parser::MARKER_PREFIX . "-gallery-" . sprintf( '%08X', $parser->mMarkerIndex - 1 ) . Parser::MARKER_SUFFIX,
$gallery
);
return true;
}
public static function onAllInfoboxesQueryRecached() {
$cache = ObjectCache::getMainWANInstance();
$cache->delete( $cache->makeKey( __CLASS__, ApiQueryAllinfoboxes::MCACHE_KEY ) );
$cache->delete( $cache->makeKey( ApiQueryAllinfoboxes::MCACHE_KEY ) );
return true;
}