Completed
Push — master ( 364599...be4002 )
by Stephan
02:10
created

PurgePage.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace PurgePage;
4
5
class PurgePage {
6
7
	public static function init() {
8
		$GLOBALS[ 'wgExtensionMessagesFiles' ][ 'PurgePageMagic' ] = __DIR__ . '/PurgePage.magic.php';
9
	}
10
11
	public static function registerParserFunction( \Parser &$parser ) {
12
13
		$parser->setFunctionHook( 'purge', function ( $parser ) {
0 ignored issues
show
The parameter $parser is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
14
15
			$params = func_get_args();
16
17
			if ( isset( $params[ 0 ] ) && isset( $params[ 1 ] ) ) {
18
19
				$pageName = $params[ 1 ];
20
21
				$title = \Title::newFromText( $pageName );
22
23
				if ( $title->isContentPage() && $title->exists() ) {
24
					\WikiPage::factory( $title )->doPurge();
25
				}
26
27
			}
28
29
		} );
30
31
		return true;
32
	}
33
}
34