From f0cac4fcf11a131cf6edbd2a0de8b48e97db8293 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Wed, 5 Jan 2011 03:31:51 +0000 Subject: [PATCH] * (bug 26498) allow LinksUpdate with API Original patch by Umherirrender. Tweaked to take account of User->pingLimiter() (ie only update links if not limited) Possible TODO: Error if we are limited? $this->dieUsageMsg( array( 'actionthrottledtext' ) ); seems a bit harsh Maybe just have a linkupdate="$this->parseMsg( array( 'actionthrottledtext' ) )" in the result? Or something. Definately notification of error to some respect is needed. Just dieing and stopping the whole process is OTT? --- RELEASE-NOTES | 1 + includes/api/ApiPurge.php | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 45108fbcc8..500e7150ea 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -73,6 +73,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 25135) add "normalized" to action=parse * (bug 26460) Add support for listing category members by category pageid * (bug 26482) add a imimages param to prop=images +* (bug 26498) allow LinksUpdate with API === Languages updated in 1.18 === diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php index 2f4648be2c..9a45db124e 100644 --- a/includes/api/ApiPurge.php +++ b/includes/api/ApiPurge.php @@ -68,6 +68,26 @@ class ApiPurge extends ApiBase { $article = MediaWiki::articleFromTitle( $title ); $article->doPurge(); // Directly purge and skip the UI part of purge(). $r['purged'] = ''; + + if( $params['forcelinkupdate'] ) { + if ( !$wgUser->pingLimiter() ) { + global $wgParser, $wgEnableParserCache; + $popts = new ParserOptions(); + $p_result = $wgParser->parse( $article->getContent(), $title, $popts ); + + # Update the links tables + $u = new LinksUpdate( $title, $p_result ); + $u->doUpdate(); + + $r['linkupdate'] = ''; + + if ( $wgEnableParserCache ) { + $pcache = ParserCache::singleton(); + $pcache->save( $p_result, $article, $popts ); + } + } + } + $result[] = $r; } $this->getResult()->setIndexedTagName( $result, 'page' ); @@ -83,13 +103,15 @@ class ApiPurge extends ApiBase { 'titles' => array( ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_REQUIRED => true - ) + ), + 'forcelinkupdate' => false, ); } public function getParamDescription() { return array( 'titles' => 'A list of titles', + 'forcelinkupdate' => 'Update the links tables', ); } -- 2.20.1