r79638 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79637‎ | r79638 | r79639 >
Date:03:31, 5 January 2011
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
* (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?
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiPurge.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiPurge.php
@@ -68,6 +68,26 @@
6969 $article = MediaWiki::articleFromTitle( $title );
7070 $article->doPurge(); // Directly purge and skip the UI part of purge().
7171 $r['purged'] = '';
 72+
 73+ if( $params['forcelinkupdate'] ) {
 74+ if ( !$wgUser->pingLimiter() ) {
 75+ global $wgParser, $wgEnableParserCache;
 76+ $popts = new ParserOptions();
 77+ $p_result = $wgParser->parse( $article->getContent(), $title, $popts );
 78+
 79+ # Update the links tables
 80+ $u = new LinksUpdate( $title, $p_result );
 81+ $u->doUpdate();
 82+
 83+ $r['linkupdate'] = '';
 84+
 85+ if ( $wgEnableParserCache ) {
 86+ $pcache = ParserCache::singleton();
 87+ $pcache->save( $p_result, $article, $popts );
 88+ }
 89+ }
 90+ }
 91+
7292 $result[] = $r;
7393 }
7494 $this->getResult()->setIndexedTagName( $result, 'page' );
@@ -83,13 +103,15 @@
84104 'titles' => array(
85105 ApiBase::PARAM_ISMULTI => true,
86106 ApiBase::PARAM_REQUIRED => true
87 - )
 107+ ),
 108+ 'forcelinkupdate' => false,
88109 );
89110 }
90111
91112 public function getParamDescription() {
92113 return array(
93114 'titles' => 'A list of titles',
 115+ 'forcelinkupdate' => 'Update the links tables',
94116 );
95117 }
96118
Index: trunk/phase3/RELEASE-NOTES
@@ -73,6 +73,7 @@
7474 * (bug 25135) add "normalized" to action=parse
7575 * (bug 26460) Add support for listing category members by category pageid
7676 * (bug 26482) add a imimages param to prop=images
 77+* (bug 26498) allow LinksUpdate with API
7778
7879 === Languages updated in 1.18 ===
7980

Follow-up revisions

RevisionCommit summaryAuthorDate
r79654Followup r79638...reedy17:57, 5 January 2011

Comments

#Comment by Reedy (talk | contribs)   04:16, 5 January 2011

Maybe just a warning about being rate limited?

#Comment by Umherirrender (talk | contribs)   16:21, 5 January 2011

Adding a warning and than stop linkupdate is ok.

$forcelinkupdate = $params['forcelinkupdate'];
...
 if( $forcelinkupdate ) {
  if ( !$wgUser->pingLimiter() ) {
   ...
  } else {
   $forcelinkupdate = false;
   $this->setWarning( ... );
  }
 }
...

Status & tagging log