* (bug 26498) allow LinksUpdate with API
authorSam Reed <reedy@users.mediawiki.org>
Wed, 5 Jan 2011 03:31:51 +0000 (03:31 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Wed, 5 Jan 2011 03:31:51 +0000 (03:31 +0000)
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
includes/api/ApiPurge.php

index 45108fb..500e715 100644 (file)
@@ -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 ===
 
index 2f4648b..9a45db1 100644 (file)
@@ -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',
                );
        }