Index: branches/apiedit/phase3/includes/api/ApiQueryRevisions.php |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | parent :: __construct($query, $moduleName, 'rv'); |
43 | 43 | } |
44 | 44 | |
45 | | - private $fld_ids = false, $fld_flags = false, $fld_timestamp = false, |
| 45 | + private $fld_ids = false, $fld_lastid = false, $fld_flags = false, $fld_timestamp = false, |
46 | 46 | $fld_comment = false, $fld_user = false, $fld_content = false; |
47 | 47 | |
48 | 48 | public function execute() { |
— | — | @@ -78,10 +78,13 @@ |
79 | 79 | $this->addFields('rev_page'); |
80 | 80 | |
81 | 81 | // Optional fields |
82 | | - $this->fld_ids = isset ($prop['ids']); |
| 82 | + // lastid automatically sets ids and timestamp |
| 83 | + // because it needs them internally |
| 84 | + $this->fld_lastid = isset ($prop['lastid']); |
| 85 | + $this->fld_ids = isset ($prop['ids']) || $this->fld_lastid); |
83 | 86 | // $this->addFieldsIf('rev_text_id', $this->fld_ids); // should this be exposed? |
84 | 87 | $this->fld_flags = $this->addFieldsIf('rev_minor_edit', isset ($prop['flags'])); |
85 | | - $this->fld_timestamp = $this->addFieldsIf('rev_timestamp', isset ($prop['timestamp'])); |
| 88 | + $this->fld_timestamp = $this->addFieldsIf('rev_timestamp', isset ($prop['timestamp']) || $this->fld_lastid); |
86 | 89 | $this->fld_comment = $this->addFieldsIf('rev_comment', isset ($prop['comment'])); |
87 | 90 | |
88 | 91 | if (isset ($prop['user'])) { |
— | — | @@ -180,7 +183,21 @@ |
181 | 184 | $this->setContinueEnumParameter('startid', intval($row->rev_id)); |
182 | 185 | break; |
183 | 186 | } |
| 187 | + $rowArr = $this->extractRowInfo($row); |
184 | 188 | |
| 189 | + if($this->fld_lastid) { |
| 190 | + $this->resetQueryParams(); |
| 191 | + $this->addTables('revision'); |
| 192 | + $this->addFields('rev_id'); |
| 193 | + $this->addWhereFld('rev_page', $rowArr['pageid']); |
| 194 | + $this->addWhere("rev_timestamp < '{$row->rev_timestamp}'"); |
| 195 | + $this->addOption('LIMIT', 1); |
| 196 | + $this->addOption('ORDER BY', 'rev_timestamp DESC'); |
| 197 | + $res2 = $this->select(__METHOD__); |
| 198 | + $row2 = $db->fetchObject($res2); |
| 199 | + $rowArr['lastid'] = $row2->rev_id; |
| 200 | + } |
| 201 | + |
185 | 202 | $this->getResult()->addValue( |
186 | 203 | array ( |
187 | 204 | 'query', |
— | — | @@ -188,7 +205,7 @@ |
189 | 206 | intval($row->rev_page), |
190 | 207 | 'revisions'), |
191 | 208 | null, |
192 | | - $this->extractRowInfo($row)); |
| 209 | + $rowArr); |
193 | 210 | } |
194 | 211 | $db->freeResult($res); |
195 | 212 | |
— | — | @@ -245,6 +262,7 @@ |
246 | 263 | ApiBase :: PARAM_DFLT => 'ids|timestamp|flags|comment|user', |
247 | 264 | ApiBase :: PARAM_TYPE => array ( |
248 | 265 | 'ids', |
| 266 | + 'lastid', |
249 | 267 | 'flags', |
250 | 268 | 'timestamp', |
251 | 269 | 'user', |
Index: branches/apiedit/phase3/RELEASE-NOTES |
— | — | @@ -286,6 +286,7 @@ |
287 | 287 | * (bug 10260) Show page protection status |
288 | 288 | * (bug 10392) Include MediaWiki version details in version output |
289 | 289 | * (bug 10411) Site language in meta=siteinfo |
| 290 | +* (bug 10297) include previous revision ID in prop=revisions |
290 | 291 | |
291 | 292 | == Maintenance script changes since 1.10 == |
292 | 293 | |