Index: trunk/phase3/includes/api/ApiParse.php |
— | — | @@ -67,7 +67,7 @@ |
68 | 68 | $wgLang = Language::factory( $params['uselang'] ); |
69 | 69 | } |
70 | 70 | |
71 | | - $popts = new ParserOptions(); |
| 71 | + $popts = ParserOptions::newFromContext( $this->getContext() ); |
72 | 72 | $popts->setTidy( true ); |
73 | 73 | $popts->enableLimitReport( !$params['disablepp'] ); |
74 | 74 | |
— | — | @@ -93,16 +93,12 @@ |
94 | 94 | |
95 | 95 | // If for some reason the "oldid" is actually the current revision, it may be cached |
96 | 96 | if ( $titleObj->getLatestRevID() === intval( $oldid ) ) { |
97 | | - $articleObj = new Article( $titleObj, 0 ); |
98 | | - |
99 | 97 | // May get from/save to parser cache |
100 | | - $p_result = $this->getParsedSectionOrText( $articleObj, $titleObj, $popts, $pageid, |
| 98 | + $p_result = $this->getParsedSectionOrText( $titleObj, $popts, $pageid, |
101 | 99 | isset( $prop['wikitext'] ) ) ; |
102 | 100 | } else { // This is an old revision, so get the text differently |
103 | | - $this->text = $rev->getText( Revision::FOR_THIS_USER ); |
| 101 | + $this->text = $rev->getText( Revision::FOR_THIS_USER, $this->getUser() ); |
104 | 102 | |
105 | | - $wgTitle = $titleObj; |
106 | | - |
107 | 103 | if ( $this->section !== false ) { |
108 | 104 | $this->text = $this->getSectionText( $this->text, 'r' . $rev->getId() ); |
109 | 105 | } |
— | — | @@ -152,13 +148,12 @@ |
153 | 149 | } |
154 | 150 | $wgTitle = $titleObj; |
155 | 151 | |
156 | | - $articleObj = new Article( $titleObj, 0 ); |
157 | 152 | if ( isset( $prop['revid'] ) ) { |
158 | | - $oldid = $articleObj->getRevIdFetched(); |
| 153 | + $oldid = $titleObj->getLatestRevID(); |
159 | 154 | } |
160 | 155 | |
161 | 156 | // Potentially cached |
162 | | - $p_result = $this->getParsedSectionOrText( $articleObj, $titleObj, $popts, $pageid, |
| 157 | + $p_result = $this->getParsedSectionOrText( $titleObj, $popts, $pageid, |
163 | 158 | isset( $prop['wikitext'] ) ) ; |
164 | 159 | } |
165 | 160 | } else { // Not $oldid, $pageid, $page. Hence based on $text |
— | — | @@ -308,18 +303,19 @@ |
309 | 304 | } |
310 | 305 | |
311 | 306 | /** |
312 | | - * @param $articleObj Article |
313 | 307 | * @param $titleObj Title |
314 | 308 | * @param $popts ParserOptions |
315 | 309 | * @param $pageId Int |
316 | 310 | * @param $getWikitext Bool |
317 | 311 | * @return ParserOutput |
318 | 312 | */ |
319 | | - private function getParsedSectionOrText( $articleObj, $titleObj, $popts, $pageId = null, $getWikitext = false ) { |
320 | | - if ( $this->section !== false ) { |
321 | | - global $wgParser; |
| 313 | + private function getParsedSectionOrText( $titleObj, $popts, $pageId = null, $getWikitext = false ) { |
| 314 | + global $wgParser; |
322 | 315 | |
323 | | - $this->text = $this->getSectionText( $articleObj->getRawText(), !is_null( $pageId ) |
| 316 | + $page = WikiPage::factory( $titleObj ); |
| 317 | + |
| 318 | + if ( $this->section !== false ) { |
| 319 | + $this->text = $this->getSectionText( $page->getRawText(), !is_null( $pageId ) |
324 | 320 | ? 'page id ' . $pageId : $titleObj->getText() ); |
325 | 321 | |
326 | 322 | // Not cached (save or load) |
— | — | @@ -327,12 +323,9 @@ |
328 | 324 | } else { |
329 | 325 | // Try the parser cache first |
330 | 326 | // getParserOutput will save to Parser cache if able |
331 | | - $pout = $articleObj->getParserOutput(); |
| 327 | + $pout = $page->getParserOutput( $popts ); |
332 | 328 | if ( $getWikitext ) { |
333 | | - $rev = Revision::newFromTitle( $titleObj ); |
334 | | - if ( $rev ) { |
335 | | - $this->text = $rev->getText(); |
336 | | - } |
| 329 | + $this->text = $page->getRawText(); |
337 | 330 | } |
338 | 331 | return $pout; |
339 | 332 | } |