| Conditions | 5 |
| Paths | 1 |
| Total Lines | 27 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | public static function registerParserFunction( \Parser &$parser ) { |
||
| 17 | |||
| 18 | $parser->setFunctionHook( 'purge', function () { |
||
| 19 | |||
| 20 | $params = func_get_args(); |
||
| 21 | |||
| 22 | if ( isset( $params[ 1 ] ) ) { |
||
| 23 | |||
| 24 | $parser = $params[ 0 ]; |
||
| 25 | $pageName = $params[ 1 ]; |
||
| 26 | |||
| 27 | $title = Title::newFromText( $pageName ); |
||
| 28 | |||
| 29 | if ( $title !== null && $title->isContentPage() && $title->exists() ) { |
||
| 30 | /** @var \ParserOptions $parserOptions */ |
||
| 31 | $parserOptions = $parser->getOptions(); |
||
| 32 | $job = Job::factory( 'parsePage', $title, [ 'user' => $parserOptions->getUser(), 'lang' => $parserOptions->getUserLang() ] ); |
||
| 33 | JobQueueGroup::singleton()->lazyPush( $job ); |
||
| 34 | } |
||
| 35 | |||
| 36 | |||
| 37 | } |
||
| 38 | |||
| 39 | } ); |
||
| 40 | |||
| 41 | return true; |
||
| 42 | } |
||
| 43 | } |
||
| 44 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: