Index: trunk/extensions/Video/VideoGalleryPopulate.php |
— | — | @@ -13,14 +13,12 @@ |
14 | 14 | |
15 | 15 | $wgHooks['ParserFirstCallInit'][] = 'wfVideoGalleryPopulate'; |
16 | 16 | |
17 | | -function wfVideoGalleryPopulate( &$parser ) { |
| 17 | +function wfVideoGalleryPopulate( $parser ) { |
18 | 18 | $parser->setHook( 'videogallerypopulate', 'VideoGalleryPopulate' ); |
19 | 19 | return true; |
20 | 20 | } |
21 | 21 | |
22 | 22 | function VideoGalleryPopulate( $input, $args, $parser ) { |
23 | | - global $wgOut; |
24 | | - |
25 | 23 | $parser->disableCache(); |
26 | 24 | |
27 | 25 | $category = ( isset( $args['category'] ) ) ? $args['category'] : ''; |
— | — | @@ -30,9 +28,13 @@ |
31 | 29 | return ''; |
32 | 30 | } |
33 | 31 | |
34 | | - // Why do we initialize a new instance of Parser here, I wonder? |
35 | | - $parser = new Parser(); |
36 | | - $category = $parser->transformMsg( $category, $wgOut->parserOptions() ); |
| 32 | + // Use Parser::recursivePreprocess() if available instead of creating another Parser instance |
| 33 | + if ( is_callable( array( $parser, 'recursivePreprocess' ) ) ) { |
| 34 | + $category = $parser->recursivePreprocess( $category ); |
| 35 | + } else { |
| 36 | + $newParser = new Parser(); |
| 37 | + $category = $newParser->preprocess( $category, $parser->getTitle(), $parser->getOptions() ); |
| 38 | + } |
37 | 39 | $category_title = Title::newFromText( $category ); |
38 | 40 | if( !( $category_title instanceof Title ) ) { |
39 | 41 | return ''; |
— | — | @@ -75,4 +77,4 @@ |
76 | 78 | } |
77 | 79 | |
78 | 80 | return $gallery->toHtml(); |
79 | | -} |
\ No newline at end of file |
| 81 | +} |