38 $block = $user->getBlock();
48 $forceLinkUpdate =
$params[
'forcelinkupdate'];
49 $forceRecursiveLinkUpdate =
$params[
'forcerecursivelinkupdate'];
53 $result = $pageSet->getInvalidTitlesAndRevisions();
55 foreach ( $pageSet->getGoodTitles() as $title ) {
58 $page = WikiPage::factory( $title );
59 if ( !$user->pingLimiter(
'purge' ) ) {
67 if ( $forceLinkUpdate || $forceRecursiveLinkUpdate ) {
68 if ( !$user->pingLimiter(
'linkpurge' ) ) {
69 $popts = $page->makeParserOptions(
'canonical' );
71 # Parse content; note that HTML generation is only needed if we want to cache the result.
72 $content = $page->getContent( Revision::RAW );
74 $enableParserCache = $this->
getConfig()->get(
'EnableParserCache' );
75 $p_result = $content->getParserOutput(
82 # Logging to better see expensive usage patterns
83 if ( $forceRecursiveLinkUpdate ) {
84 LoggerFactory::getInstance(
'RecursiveLinkPurge' )->info(
85 "Recursive link purge enqueued for {title}",
87 'user' => $this->
getUser()->getName(),
88 'title' => $title->getPrefixedText()
93 # Update the links tables
94 $updates = $content->getSecondaryDataUpdates(
95 $title,
null, $forceRecursiveLinkUpdate, $p_result );
96 foreach ( $updates as $update ) {
97 $update->setCause(
'api-purge', $this->
getUser()->getName() );
98 DeferredUpdates::addUpdate( $update, DeferredUpdates::PRESEND );
101 $r[
'linkupdate'] =
true;
103 if ( $enableParserCache ) {
104 $pcache = MediaWikiServices::getInstance()->getParserCache();
105 $pcache->save( $p_result, $page, $popts );
110 $forceLinkUpdate =
false;
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.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
setContinuationManager(ApiContinuationManager $manager=null)
Set the continuation manager.
getResult()
Get the result object.
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 class contains a list of pages that the client has requested.
API interface for page purging.
getAllowedParams( $flags=0)
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.
isWriteMode()
Indicates whether this module requires write mode.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
namespace being checked & $result