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