44 parent::__construct( $mainModule, $moduleName );
55 $block = $user->getBlock();
56 if ( $block && $block->isSitewide() ) {
65 $forceLinkUpdate = $params[
'forcelinkupdate'];
66 $forceRecursiveLinkUpdate = $params[
'forcerecursivelinkupdate'];
70 $result = $pageSet->getInvalidTitlesAndRevisions();
72 foreach ( $pageSet->getGoodTitles() as
$title ) {
74 ApiQueryBase::addTitleInfo( $r,
$title );
75 $page = $this->wikiPageFactory->newFromTitle(
$title );
76 if ( !$user->pingLimiter(
'purge' ) ) {
84 if ( $forceLinkUpdate || $forceRecursiveLinkUpdate ) {
85 if ( !$user->pingLimiter(
'linkpurge' ) ) {
86 # Logging to better see expensive usage patterns
87 if ( $forceRecursiveLinkUpdate ) {
88 LoggerFactory::getInstance(
'RecursiveLinkPurge' )->info(
89 "Recursive link purge enqueued for {title}",
91 'user' => $this->
getUser()->getName(),
92 'title' =>
$title->getPrefixedText()
97 $page->updateParserCache( [
98 'causeAction' =>
'api-purge',
99 'causeAgent' => $this->
getUser()->getName(),
101 $page->doSecondaryDataUpdates( [
102 'recursive' => $forceRecursiveLinkUpdate,
103 'causeAction' =>
'api-purge',
104 'causeAgent' => $this->
getUser()->getName(),
105 'defer' => DeferredUpdates::PRESEND,
107 $r[
'linkupdate'] =
true;
110 $forceLinkUpdate =
false;
117 ApiResult::setIndexedTagName( $result,
'page' );
118 $apiResult->addValue(
null, $this->
getModuleName(), $result );
120 $values = $pageSet->getNormalizedTitlesAsResult( $apiResult );
122 $apiResult->addValue(
null,
'normalized', $values );
124 $values = $pageSet->getConvertedTitlesAsResult( $apiResult );
126 $apiResult->addValue(
null,
'converted', $values );
128 $values = $pageSet->getRedirectTitlesAsResult( $apiResult );
130 $apiResult->addValue(
null,
'redirects', $values );
134 $continuationManager->setContinuationIntoResult( $apiResult );
142 if ( $this->mPageSet ===
null ) {
159 'forcelinkupdate' =>
false,
160 'forcerecursivelinkupdate' =>
false,
166 $result += $this->
getPageSet()->getFinalParams( $flags );
174 'action=purge&titles=Main_Page|API'
175 =>
'apihelp-purge-example-simple',
176 'action=purge&generator=allpages&gapnamespace=0&gaplimit=10'
177 =>
'apihelp-purge-example-generator',
182 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Purge';
This abstract class implements many basic API functions, and is the base of all API classes.
setContinuationManager(ApiContinuationManager $manager=null)
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
getModuleName()
Get the name of the module being executed by this instance.
dieBlocked(Block $block)
Throw an ApiUsageException, which will (if uncaught) call the main module's error handler and die wit...
This manages continuation state.
This is the main API class, used for both external and internal processing.
This class contains a list of pages that the client has requested.
API interface for page purging.
getAllowedParams( $flags=0)
WikiPageFactory $wikiPageFactory
getExamplesMessages()
Returns usage examples for this module.
getPageSet()
Get a cached instance of an ApiPageSet object.
mustBePosted()
Indicates whether this module must be called with a POST request.
execute()
Purges the cache of a page.
getHelpUrls()
Return links to more detailed help pages about the module.
__construct(ApiMain $mainModule, $moduleName, WikiPageFactory $wikiPageFactory)
isWriteMode()
Indicates whether this module requires write mode.