$this->getContext()->setLanguage( Language::factory( $params['uselang'] ) );
}
- $popts = ParserOptions::newFromContext( $this->getContext() );
- $popts->setTidy( true );
- $popts->enableLimitReport( !$params['disablepp'] );
-
$redirValues = null;
// Return result
}
$titleObj = $rev->getTitle();
-
$wgTitle = $titleObj;
+ $pageObj = WikiPage::factory( $titleObj );
+ $popts = $pageObj->makeParserOptions( $this->getContext() );
+ $popts->enableLimitReport( !$params['disablepp'] );
// If for some reason the "oldid" is actually the current revision, it may be cached
- if ( $titleObj->getLatestRevID() === intval( $oldid ) ) {
+ if ( $rev->isCurrent() ) {
// May get from/save to parser cache
$pageObj = WikiPage::factory( $titleObj );
- $p_result = $this->getParsedContent( $pageObj, $popts, $pageid, isset( $prop['wikitext'] ) ) ;
+ $p_result = $this->getParsedContent( $pageObj, $popts, $pageid,
+ isset( $prop['wikitext'] ) ) ;
} else { // This is an old revision, so get the text differently
$this->content = $rev->getContent( Revision::FOR_THIS_USER, $this->getUser() );
foreach ( (array)$redirValues as $r ) {
$to = $r['to'];
}
- $titleObj = Title::newFromText( $to );
- } else {
- if ( !is_null ( $pageid ) ) {
- $reqParams['pageids'] = $pageid;
- $titleObj = Title::newFromID( $pageid );
- } else { // $page
- $to = $page;
- $titleObj = Title::newFromText( $to );
- }
- }
- if ( !is_null ( $pageid ) ) {
- if ( !$titleObj ) {
- // Still throw nosuchpageid error if pageid was provided
- $this->dieUsageMsg( array( 'nosuchpageid', $pageid ) );
- }
- } elseif ( !$titleObj || !$titleObj->exists() ) {
- $this->dieUsage( "The page you specified doesn't exist", 'missingtitle' );
+ $pageParams = array( 'title' => $to );
+ } elseif ( !is_null( $pageid ) ) {
+ $pageParams = array( 'pageid' => $pageid );
+ } else { // $page
+ $pageParams = array( 'title' => $page );
}
+
+ $pageObj = $this->getTitleOrPageId( $pageParams, 'fromdb' );
+ $titleObj = $pageObj->getTitle();
$wgTitle = $titleObj;
if ( isset( $prop['revid'] ) ) {
- $oldid = $titleObj->getLatestRevID();
+ $oldid = $pageObj->getLatest();
}
- $pageObj = WikiPage::factory( $titleObj );
+
+ $popts = $pageObj->makeParserOptions( $this->getContext() );
+ $popts->enableLimitReport( !$params['disablepp'] );
// Potentially cached
- $p_result = $this->getParsedContent( $pageObj, $popts, $pageid, isset( $prop['wikitext'] ) ) ;
+ $p_result = $this->getParsedContent( $pageObj, $popts, $pageid,
+ isset( $prop['wikitext'] ) ) ;
}
} else { // Not $oldid, $pageid, $page. Hence based on $text
$titleObj = Title::newFromText( $title );
$this->dieUsageMsg( array( 'invalidtitle', $title ) );
}
$wgTitle = $titleObj;
+ $pageObj = WikiPage::factory( $titleObj );
+
+ $popts = $pageObj->makeParserOptions( $this->getContext() );
+ $popts->enableLimitReport( !$params['disablepp'] );
if ( is_null( $text ) ) {
$this->dieUsage( 'The text parameter should be passed with the title parameter. Should you be using the "page" parameter instead?', 'params' );