Index: trunk/phase3/includes/api/ApiParse.php |
— | — | @@ -96,9 +96,9 @@ |
97 | 97 | // If for some reason the "oldid" is actually the current revision, it may be cached |
98 | 98 | if ( $titleObj->getLatestRevID() === intval( $oldid ) ) { |
99 | 99 | $articleObj = new Article( $titleObj ); |
100 | | - $wgTitle = $titleObj; |
101 | 100 | |
102 | | - $p_result = $articleObj->getParserOutput(); |
| 101 | + $p_result = $this->getParsedSectionOrText( $articleObj, $titleObj, $pageid ) ; |
| 102 | + |
103 | 103 | } else { |
104 | 104 | $text = $rev->getText( Revision::FOR_THIS_USER ); |
105 | 105 | |
— | — | @@ -147,15 +147,7 @@ |
148 | 148 | $oldid = $articleObj->getRevIdFetched(); |
149 | 149 | } |
150 | 150 | |
151 | | - if ( $this->section !== false ) { |
152 | | - $text = $this->getSectionText( $text, !is_null ( $pageid ) |
153 | | - ? 'page id ' . $pageid : $titleObj->getText() ); |
154 | | - |
155 | | - $p_result = $wgParser->parse( $text, $titleObj, $popts ); |
156 | | - } else { |
157 | | - // Try the parser cache first |
158 | | - $p_result = $articleObj->getParserOutput(); |
159 | | - } |
| 151 | + $p_result = $this->getParsedSectionOrText( $articleObj, $titleObj, $pageid ) ; |
160 | 152 | } |
161 | 153 | } else { |
162 | 154 | $titleObj = Title::newFromText( $title ); |
— | — | @@ -286,6 +278,26 @@ |
287 | 279 | } |
288 | 280 | } |
289 | 281 | |
| 282 | + /** |
| 283 | + * @param $articleObj Article |
| 284 | + * @param $titleObj Title |
| 285 | + * @param $pageId Int |
| 286 | + * @return ParserOutput |
| 287 | + */ |
| 288 | + private function getParsedSectionOrText( $articleObj, $titleObj, $pageId = null ) { |
| 289 | + global $wgParser; |
| 290 | + |
| 291 | + if ( $this->section !== false ) { |
| 292 | + $text = $this->getSectionText( $text, !is_null ( $pageId ) |
| 293 | + ? 'page id ' . $pageId : $titleObj->getText() ); |
| 294 | + |
| 295 | + return $wgParser->parse( $text, $titleObj, $popts ); |
| 296 | + } else { |
| 297 | + // Try the parser cache first |
| 298 | + return $articleObj->getParserOutput(); |
| 299 | + } |
| 300 | + } |
| 301 | + |
290 | 302 | private function getSectionText( $text, $what ) { |
291 | 303 | global $wgParser; |
292 | 304 | $text = $wgParser->getSection( $text, $this->section, false ); |