Index: trunk/phase3/includes/api/ApiEditPage.php |
— | — | @@ -82,11 +82,6 @@ |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | | - // Some functions depend on $wgTitle == $ep->mTitle |
87 | | - // TODO: Make them not or check if they still do |
88 | | - global $wgTitle; |
89 | | - $wgTitle = $titleObj; |
90 | | - |
91 | 86 | if ( $params['createonly'] && $titleObj->exists() ) { |
92 | 87 | $this->dieUsageMsg( 'createonly-exists' ); |
93 | 88 | } |
— | — | @@ -103,7 +98,8 @@ |
104 | 99 | $this->dieUsageMsg( $errors[0] ); |
105 | 100 | } |
106 | 101 | |
107 | | - $articleObj = new Article( $titleObj ); |
| 102 | + $articleObj = Article::newFromTitle( $titleObj, $this->getContext() ); |
| 103 | + |
108 | 104 | $toMD5 = $params['text']; |
109 | 105 | if ( !is_null( $params['appendtext'] ) || !is_null( $params['prependtext'] ) ) |
110 | 106 | { |
— | — | @@ -174,9 +170,6 @@ |
175 | 171 | $this->dieUsageMsg( 'hashcheckfailed' ); |
176 | 172 | } |
177 | 173 | |
178 | | - $ep = new EditPage( $articleObj ); |
179 | | - $ep->setContextTitle( $titleObj ); |
180 | | - |
181 | 174 | // EditPage wants to parse its stuff from a WebRequest |
182 | 175 | // That interface kind of sucks, but it's workable |
183 | 176 | $reqArr = array( |
— | — | @@ -234,8 +227,16 @@ |
235 | 228 | $reqArr['wpWatchthis'] = ''; |
236 | 229 | } |
237 | 230 | |
238 | | - global $wgRequest; |
239 | | - $req = new DerivativeRequest( $wgRequest, $reqArr, true ); |
| 231 | + global $wgTitle, $wgRequest; |
| 232 | + |
| 233 | + $req = new DerivativeRequest( $this->getRequest(), $reqArr, true ); |
| 234 | + |
| 235 | + // Some functions depend on $wgTitle == $ep->mTitle |
| 236 | + // TODO: Make them not or check if they still do |
| 237 | + $wgTitle = $titleObj; |
| 238 | + |
| 239 | + $ep = new EditPage( $articleObj ); |
| 240 | + $ep->setContextTitle( $titleObj ); |
240 | 241 | $ep->importFormData( $req ); |
241 | 242 | |
242 | 243 | // Run hooks |
— | — | @@ -329,19 +330,14 @@ |
330 | 331 | $r['result'] = 'Success'; |
331 | 332 | $r['pageid'] = intval( $titleObj->getArticleID() ); |
332 | 333 | $r['title'] = $titleObj->getPrefixedText(); |
333 | | - // HACK: We create a new Article object here because getRevIdFetched() |
334 | | - // refuses to be run twice, and because Title::getLatestRevId() |
335 | | - // won't fetch from the master unless we select for update, which we |
336 | | - // don't want to do. |
337 | | - $newArticle = new Article( $titleObj ); |
338 | | - $newRevId = $newArticle->getRevIdFetched(); |
| 334 | + $newRevId = $articleObj->getLatest(); |
339 | 335 | if ( $newRevId == $oldRevId ) { |
340 | 336 | $r['nochange'] = ''; |
341 | 337 | } else { |
342 | 338 | $r['oldrevid'] = intval( $oldRevId ); |
343 | 339 | $r['newrevid'] = intval( $newRevId ); |
344 | 340 | $r['newtimestamp'] = wfTimestamp( TS_ISO_8601, |
345 | | - $newArticle->getTimestamp() ); |
| 341 | + $articleObj->getTimestamp() ); |
346 | 342 | } |
347 | 343 | break; |
348 | 344 | |