r50220 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50219‎ | r50220 | r50221 >
Date:14:07, 5 May 2009
Author:tstarling
Status:deferred
Tags:
Comment:
API backports:
* r49999: avoid table scan and general breakage on list=deletedrevs continue
* r50132/r50134/r50218: Define $wgTitle, to avoid various fatal errors and exceptions
Modified paths:
  • /branches/REL1_15/phase3 (modified) (history)
  • /branches/REL1_15/phase3/api.php (modified) (history)
  • /branches/REL1_15/phase3/includes (modified) (history)
  • /branches/REL1_15/phase3/includes/api (modified) (history)
  • /branches/REL1_15/phase3/includes/api/ApiEditPage.php (modified) (history)
  • /branches/REL1_15/phase3/includes/api/ApiQueryDeletedrevs.php (modified) (history)
  • /branches/REL1_15/phase3/includes/specials (modified) (history)

Diff [purge]

Index: branches/REL1_15/phase3/includes/api/ApiQueryDeletedrevs.php
@@ -139,16 +139,20 @@
140140 $this->getDB()->addQuotes($params['excludeuser']));
141141 }
142142
143 - if(!is_null($params['continue']) && $mode == 'all')
 143+ if(!is_null($params['continue']) && ($mode == 'all' || $mode == 'revs'))
144144 {
145145 $cont = explode('|', $params['continue']);
146 - if(count($cont) != 2)
 146+ if(count($cont) != 3)
147147 $this->dieUsage("Invalid continue param. You should pass the original value returned by the previous query", "badcontinue");
148 - $title = $this->getDB()->strencode($this->titleToKey($cont[0]));
149 - $ts = $this->getDB()->strencode($cont[1]);
150 - $this->addWhere("ar_title > '$title' OR " .
 148+ $ns = intval($cont[0]);
 149+ $title = $this->getDB()->strencode($this->titleToKey($cont[1]));
 150+ $ts = $this->getDB()->strencode($cont[2]);
 151+ $op = ($params['dir'] == 'newer' ? '>' : '<');
 152+ $this->addWhere("ar_namespace $op $ns OR " .
 153+ "(ar_namespace = $ns AND " .
 154+ "(ar_title $op '$title' OR " .
151155 "(ar_title = '$title' AND " .
152 - "ar_timestamp >= '$ts')");
 156+ "ar_timestamp = '$ts')))");
153157 }
154158
155159 $this->addOption('LIMIT', $limit + 1);
@@ -182,9 +186,9 @@
183187 if(++$count > $limit)
184188 {
185189 // We've had enough
186 - if($mode == 'all')
187 - $this->setContinueEnumParameter('continue', $this->keyToTitle($row->ar_title) . '|' .
188 - $row->ar_timestamp);
 190+ if($mode == 'all' || $mode == 'revs')
 191+ $this->setContinueEnumParameter('continue', intval($row->ar_namespace) . '|' .
 192+ $this->keyToTitle($row->ar_title) . '|' . $row->ar_timestamp);
189193 else
190194 $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->ar_timestamp));
191195 break;
@@ -227,9 +231,9 @@
228232 }
229233 if(!$fit)
230234 {
231 - if($mode == 'all')
232 - $this->setContinueEnumParameter('continue', $this->keyToTitle($row->ar_title) . '|' .
233 - $row->ar_timestamp);
 235+ if($mode == 'all' || $mode == 'revs')
 236+ $this->setContinueEnumParameter('continue', intval($row->ar_namespace) . '|' .
 237+ $this->keyToTitle($row->ar_title) . '|' . $row->ar_timestamp);
234238 else
235239 $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->ar_timestamp));
236240 break;
Index: branches/REL1_15/phase3/includes/api/ApiEditPage.php
@@ -58,6 +58,9 @@
5959 $titleObj = Title::newFromText($params['title']);
6060 if(!$titleObj)
6161 $this->dieUsageMsg(array('invalidtitle', $params['title']));
 62+ // Some functions depend on $wgTitle == $ep->mTitle
 63+ global $wgTitle;
 64+ $wgTitle = $titleObj;
6265
6366 if($params['createonly'] && $titleObj->exists())
6467 $this->dieUsageMsg(array('createonly-exists'));
@@ -197,10 +200,6 @@
198201 # Do the actual save
199202 $oldRevId = $articleObj->getRevIdFetched();
200203 $result = null;
201 - # *Something* is setting $wgTitle to a title corresponding to "Msg",
202 - # but that breaks API mode detection through is_null($wgTitle)
203 - global $wgTitle;
204 - $wgTitle = null;
205204 # Fake $wgRequest for some hooks inside EditPage
206205 # FIXME: This interface SUCKS
207206 $oldRequest = $wgRequest;
Property changes on: branches/REL1_15/phase3/includes/api
___________________________________________________________________
Name: svn:mergeinfo
208207 - /trunk/phase3/includes/api:48813-48814,48819,48836,48886,48892,48909,48989,48992,49002,49051,49068,49086,49191-49192,49212,49682,49685,49730,49775,49954,49956,50041,50070,50169
209208 + /trunk/phase3/includes/api:48813-48814,48819,48836,48886,48892,48909,48989,48992,49002,49051,49068,49086,49191-49192,49212,49682,49685,49730,49775,49954,49956,49999,50041,50070,50132,50134,50169,50218
Property changes on: branches/REL1_15/phase3/includes/specials
___________________________________________________________________
Name: svn:mergeinfo
210209 - /trunk/phase3/includes/specials:48836,48886,48892,48989,48992-48993,49002,49051,49068,49086,49191-49192,49212,49682,49685,49730,49775,49954,49956,50041,50070,50169
/trunk/phase3/includes/specials/specials:48993
211210 + /trunk/phase3/includes/specials:48836,48886,48892,48989,48992-48993,49002,49051,49068,49086,49191-49192,49212,49682,49685,49730,49775,49954,49956,49999,50041,50070,50132,50134,50169,50218
/trunk/phase3/includes/specials/specials:48993
Property changes on: branches/REL1_15/phase3/includes
___________________________________________________________________
Name: svn:mergeinfo
212211 - /trunk/phase3/includes:48836,48886,48892,48989,48992,49002,49051,49068,49086,49191-49192,49212,49682,49685,49730,49775,49954,49956,50041,50070,50169
/trunk/phase3/includes/specials:48993
213212 + /trunk/phase3/includes:48836,48886,48892,48989,48992,49002,49051,49068,49086,49191-49192,49212,49682,49685,49730,49775,49954,49956,49999,50041,50070,50132,50134,50169,50218
/trunk/phase3/includes/specials:48993
Index: branches/REL1_15/phase3/api.php
@@ -69,6 +69,13 @@
7070 die(1);
7171 }
7272
 73+// So extensions can check whether they're running in API mode
 74+define('MW_API', true);
 75+
 76+// Set a dummy $wgTitle, because $wgTitle == null breaks various things
 77+// In a perfect world this wouldn't be necessary
 78+$wgTitle = Title::newFromText('API');
 79+
7380 /* Construct an ApiMain with the arguments passed via the URL. What we get back
7481 * is some form of an ApiMain, possibly even one that produces an error message,
7582 * but we don't care here, as that is handled by the ctor.
Property changes on: branches/REL1_15/phase3
___________________________________________________________________
Name: svn:mergeinfo
7683 - /trunk/phase3:48814,48836,48886,48892,48909,48989,48992,49002,49051,49068,49086,49191-49192,49212,49682,49685,49730,49775,49954,49956,50041,50070,50169
7784 + /trunk/phase3:48814,48836,48886,48892,48909,48989,48992,49002,49051,49068,49086,49191-49192,49212,49682,49685,49730,49775,49954,49956,49999,50041,50070,50132,50134,50169,50218

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r49999API: Fix list=deletedrevs paging bug pointed out by Splarka on IRCcatrope11:30, 28 April 2009
r50132API: Set $wgTitle to a dummy title in api.php, and introduce defined('API') a...catrope14:47, 2 May 2009
r50134Followup to r50132: I guess I was smoking some pretty good stuff therecatrope15:03, 2 May 2009
r50218Followup to r50132: rename API define constant to MW_API, per comment on CRcatrope13:22, 5 May 2009

Status & tagging log