<?php
-
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* @file
*/
+
use MediaWiki\Logger\LoggerFactory;
-use MediaWiki\MediaWikiServices;
/**
* API interface for page purging
if ( $forceLinkUpdate || $forceRecursiveLinkUpdate ) {
if ( !$user->pingLimiter( 'linkpurge' ) ) {
- $popts = $page->makeParserOptions( 'canonical' );
-
- # Parse content; note that HTML generation is only needed if we want to cache the result.
- $content = $page->getContent( Revision::RAW );
- if ( $content ) {
- $enableParserCache = $this->getConfig()->get( 'EnableParserCache' );
- $p_result = $content->getParserOutput(
- $title,
- $page->getLatest(),
- $popts,
- $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()
+ ]
);
-
- # 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 );
- foreach ( $updates as $update ) {
- $update->setCause( 'api-purge', $this->getUser()->getName() );
- DeferredUpdates::addUpdate( $update, DeferredUpdates::PRESEND );
- }
-
- $r['linkupdate'] = true;
-
- if ( $enableParserCache ) {
- $pcache = MediaWikiServices::getInstance()->getParserCache();
- $pcache->save( $p_result, $page, $popts );
- }
}
+
+ $page->updateParserCache( [
+ 'causeAction' => 'api-purge',
+ 'causeAgent' => $this->getUser()->getName(),
+ ] );
+ $page->doSecondaryDataUpdates( [
+ 'recursive' => $forceRecursiveLinkUpdate,
+ 'causeAction' => 'api-purge',
+ 'causeAgent' => $this->getUser()->getName(),
+ 'defer' => DeferredUpdates::PRESEND,
+ ] );
+ $r['linkupdate'] = true;
} else {
$this->addWarning( 'apierror-ratelimited' );
$forceLinkUpdate = false;