https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103451

Revision: 103451
Author:   ialex
Date:     2011-11-17 10:33:20 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
* 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: trunk/phase3/includes/api/ApiEditPage.php
===================================================================
--- trunk/phase3/includes/api/ApiEditPage.php   2011-11-17 10:10:40 UTC (rev 
103450)
+++ trunk/phase3/includes/api/ApiEditPage.php   2011-11-17 10:33:20 UTC (rev 
103451)
@@ -82,11 +82,6 @@
                        }
                }
 
-               // Some functions depend on $wgTitle == $ep->mTitle
-               // TODO: Make them not or check if they still do
-               global $wgTitle;
-               $wgTitle = $titleObj;
-
                if ( $params['createonly'] && $titleObj->exists() ) {
                        $this->dieUsageMsg( 'createonly-exists' );
                }
@@ -103,7 +98,8 @@
                        $this->dieUsageMsg( $errors[0] );
                }
 
-               $articleObj = new Article( $titleObj );
+               $articleObj = Article::newFromTitle( $titleObj, 
$this->getContext() );
+
                $toMD5 = $params['text'];
                if ( !is_null( $params['appendtext'] ) || !is_null( 
$params['prependtext'] ) )
                {
@@ -174,9 +170,6 @@
                        $this->dieUsageMsg( 'hashcheckfailed' );
                }
 
-               $ep = new EditPage( $articleObj );
-               $ep->setContextTitle( $titleObj );
-
                // EditPage wants to parse its stuff from a WebRequest
                // That interface kind of sucks, but it's workable
                $reqArr = array(
@@ -234,8 +227,16 @@
                        $reqArr['wpWatchthis'] = '';
                }
 
-               global $wgRequest;
-               $req = new DerivativeRequest( $wgRequest, $reqArr, true );
+               global $wgTitle, $wgRequest;
+
+               $req = new DerivativeRequest( $this->getRequest(), $reqArr, 
true );
+
+               // Some functions depend on $wgTitle == $ep->mTitle
+               // TODO: Make them not or check if they still do
+               $wgTitle = $titleObj;
+
+               $ep = new EditPage( $articleObj );
+               $ep->setContextTitle( $titleObj );
                $ep->importFormData( $req );
 
                // Run hooks
@@ -329,19 +330,14 @@
                                $r['result'] = 'Success';
                                $r['pageid'] = intval( 
$titleObj->getArticleID() );
                                $r['title'] = $titleObj->getPrefixedText();
-                               // HACK: We create a new Article object here 
because getRevIdFetched()
-                               // refuses to be run twice, and because 
Title::getLatestRevId()
-                               // won't fetch from the master unless we select 
for update, which we
-                               // don't want to do.
-                               $newArticle = new Article( $titleObj );
-                               $newRevId = $newArticle->getRevIdFetched();
+                               $newRevId = $articleObj->getLatest();
                                if ( $newRevId == $oldRevId ) {
                                        $r['nochange'] = '';
                                } else {
                                        $r['oldrevid'] = intval( $oldRevId );
                                        $r['newrevid'] = intval( $newRevId );
                                        $r['newtimestamp'] = wfTimestamp( 
TS_ISO_8601,
-                                               $newArticle->getTimestamp() );
+                                               $articleObj->getTimestamp() );
                                }
                                break;
 


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to