*
* @file
*/
+use MediaWiki\Logger\LoggerFactory;
/**
* API interface for page purging
public function execute() {
$params = $this->extractRequestParams();
- $continuationManager = new ApiContinuationManager( $this, array(), array() );
+ $continuationManager = new ApiContinuationManager( $this, [], [] );
$this->setContinuationManager( $continuationManager );
$forceLinkUpdate = $params['forcelinkupdate'];
$user = $this->getUser();
foreach ( $pageSet->getGoodTitles() as $title ) {
- $r = array();
+ $r = [];
ApiQueryBase::addTitleInfo( $r, $title );
$page = WikiPage::factory( $title );
if ( !$user->pingLimiter( 'purge' ) ) {
$page->doPurge(); // Directly purge and skip the UI part of purge().
$r['purged'] = true;
} else {
- $error = $this->parseMsg( array( 'actionthrottledtext' ) );
+ $error = $this->parseMsg( [ 'actionthrottledtext' ] );
$this->setWarning( $error['info'] );
}
$enableParserCache
);
+ # Logging to better see expensive usage patterns
+ if ( $forceRecursiveLinkUpdate ) {
+ LoggerFactory::getInstance( 'RecursiveLinkPurge' )->info(
+ "Recursive link purge enqueued for {title}",
+ [
+ 'user' => $this->getUser()->getName(),
+ 'title' => $title->getPrefixedText()
+ ]
+ );
+ }
+
# Update the links tables
$updates = $content->getSecondaryDataUpdates(
$title, null, $forceRecursiveLinkUpdate, $p_result );
$pcache->save( $p_result, $page, $popts );
}
} else {
- $error = $this->parseMsg( array( 'actionthrottledtext' ) );
+ $error = $this->parseMsg( [ 'actionthrottledtext' ] );
$this->setWarning( $error['info'] );
$forceLinkUpdate = false;
}
}
public function getAllowedParams( $flags = 0 ) {
- $result = array(
+ $result = [
'forcelinkupdate' => false,
'forcerecursivelinkupdate' => false,
- 'continue' => array(
+ 'continue' => [
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
- ),
- );
+ ],
+ ];
if ( $flags ) {
$result += $this->getPageSet()->getFinalParams( $flags );
}
}
protected function getExamplesMessages() {
- return array(
+ return [
'action=purge&titles=Main_Page|API'
=> 'apihelp-purge-example-simple',
'action=purge&generator=allpages&gapnamespace=0&gaplimit=10'
=> 'apihelp-purge-example-generator',
- );
+ ];
}
public function getHelpUrls() {