32 private $mPageSet =
null;
49 parent::__construct( $mainModule, $moduleName );
50 $this->wikiPageFactory = $wikiPageFactory;
51 $this->titleFormatter = $titleFormatter;
61 $block = $user->getBlock();
62 if ( $block && $block->isSitewide() ) {
71 $forceLinkUpdate = $params[
'forcelinkupdate'];
72 $forceRecursiveLinkUpdate = $params[
'forcerecursivelinkupdate'];
73 $pageSet = $this->getPageSet();
76 $result = $pageSet->getInvalidTitlesAndRevisions();
77 $userName = $user->getName();
79 foreach ( $pageSet->getGoodPages() as $pageIdentity ) {
80 $title = $this->titleFormatter->getPrefixedText( $pageIdentity );
82 'ns' => $pageIdentity->getNamespace(),
85 $page = $this->wikiPageFactory->newFromTitle( $pageIdentity );
86 if ( !$user->pingLimiter(
'purge' ) ) {
94 if ( $forceLinkUpdate || $forceRecursiveLinkUpdate ) {
95 if ( !$user->pingLimiter(
'linkpurge' ) ) {
96 # Logging to better see expensive usage patterns
97 if ( $forceRecursiveLinkUpdate ) {
98 LoggerFactory::getInstance(
'RecursiveLinkPurge' )->info(
99 "Recursive link purge enqueued for {title}",
107 $page->updateParserCache( [
108 'causeAction' =>
'api-purge',
109 'causeAgent' => $userName,
111 $page->doSecondaryDataUpdates( [
112 'recursive' => $forceRecursiveLinkUpdate,
113 'causeAction' =>
'api-purge',
114 'causeAgent' => $userName,
115 'defer' => DeferredUpdates::PRESEND,
117 $r[
'linkupdate'] =
true;
120 $forceLinkUpdate =
false;
128 $apiResult->addValue(
null, $this->
getModuleName(), $result );
130 $values = $pageSet->getNormalizedTitlesAsResult( $apiResult );
132 $apiResult->addValue(
null,
'normalized', $values );
134 $values = $pageSet->getConvertedTitlesAsResult( $apiResult );
136 $apiResult->addValue(
null,
'converted', $values );
138 $values = $pageSet->getRedirectTitlesAsResult( $apiResult );
140 $apiResult->addValue(
null,
'redirects', $values );
144 $continuationManager->setContinuationIntoResult( $apiResult );
151 private function getPageSet() {
154 return $this->mPageSet;
167 'forcelinkupdate' =>
false,
168 'forcerecursivelinkupdate' =>
false,
174 $result += $this->getPageSet()->getFinalParams( $flags );
181 $title = Title::newMainPage()->getPrefixedText();
182 $mp = rawurlencode( $title );
185 "action=purge&titles={$mp}|API"
186 =>
'apihelp-purge-example-simple',
187 'action=purge&generator=allpages&gapnamespace=0&gaplimit=10'
188 =>
'apihelp-purge-example-generator',
193 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.
__construct(ApiMain $mainModule, $moduleName, WikiPageFactory $wikiPageFactory, TitleFormatter $titleFormatter)
getAllowedParams( $flags=0)
getExamplesMessages()
Returns usage examples for this module.
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.
isWriteMode()
Indicates whether this module requires write mode.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Service for creating WikiPage objects.