}
}
- // 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' );
}
$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'] ) )
{
$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(
$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
$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;