r103451 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103450‎ | r103451 | r103452 >
Date:10:33, 17 November 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Use the fact that WikiPage::getLatest() is updated when editing the page since r103383
* Moved override of $wgTitle and creation of EditPage object to the place they will be used
Modified paths:
  • /trunk/phase3/includes/api/ApiEditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiEditPage.php
@@ -82,11 +82,6 @@
8383 }
8484 }
8585
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 -
9186 if ( $params['createonly'] && $titleObj->exists() ) {
9287 $this->dieUsageMsg( 'createonly-exists' );
9388 }
@@ -103,7 +98,8 @@
10499 $this->dieUsageMsg( $errors[0] );
105100 }
106101
107 - $articleObj = new Article( $titleObj );
 102+ $articleObj = Article::newFromTitle( $titleObj, $this->getContext() );
 103+
108104 $toMD5 = $params['text'];
109105 if ( !is_null( $params['appendtext'] ) || !is_null( $params['prependtext'] ) )
110106 {
@@ -174,9 +170,6 @@
175171 $this->dieUsageMsg( 'hashcheckfailed' );
176172 }
177173
178 - $ep = new EditPage( $articleObj );
179 - $ep->setContextTitle( $titleObj );
180 -
181174 // EditPage wants to parse its stuff from a WebRequest
182175 // That interface kind of sucks, but it's workable
183176 $reqArr = array(
@@ -234,8 +227,16 @@
235228 $reqArr['wpWatchthis'] = '';
236229 }
237230
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 );
240241 $ep->importFormData( $req );
241242
242243 // Run hooks
@@ -329,19 +330,14 @@
330331 $r['result'] = 'Success';
331332 $r['pageid'] = intval( $titleObj->getArticleID() );
332333 $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();
339335 if ( $newRevId == $oldRevId ) {
340336 $r['nochange'] = '';
341337 } else {
342338 $r['oldrevid'] = intval( $oldRevId );
343339 $r['newrevid'] = intval( $newRevId );
344340 $r['newtimestamp'] = wfTimestamp( TS_ISO_8601,
345 - $newArticle->getTimestamp() );
 341+ $articleObj->getTimestamp() );
346342 }
347343 break;
348344

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103383* Put the LinkCache update in WikiPage::updateRevisionOn() so that we are sur...ialex21:03, 16 November 2011

Comments

#Comment by Nikerabbit (talk | contribs)   09:54, 15 December 2011

Has that TODO been addressed?

#Comment by IAlex (talk | contribs)   19:17, 16 December 2011

I don't think so. Why was this commit marked as fixme?

#Comment by Nikerabbit (talk | contribs)   19:18, 16 December 2011

I interpreted that TODO as fixmeworthy. If it isn't, please make it clear why not.

Status & tagging log