Index: trunk/phase3/includes/api/ApiParse.php |
— | — | @@ -77,7 +77,9 @@ |
78 | 78 | $popts = new ParserOptions(); |
79 | 79 | $popts->setTidy( true ); |
80 | 80 | $popts->enableLimitReport( !$params['disablepp'] ); |
| 81 | + |
81 | 82 | $redirValues = null; |
| 83 | + |
82 | 84 | if ( !is_null( $oldid ) || !is_null( $pageid ) || !is_null( $page ) ) { |
83 | 85 | |
84 | 86 | if ( !is_null( $oldid ) ) { |
— | — | @@ -98,9 +100,9 @@ |
99 | 101 | if ( $titleObj->getLatestRevID() === intval( $oldid ) ) { |
100 | 102 | $articleObj = new Article( $titleObj, 0 ); |
101 | 103 | |
102 | | - $p_result = $this->getParsedSectionOrText( $articleObj, $titleObj, $articleObj->get, $popts, $pageid ) ; |
| 104 | + $p_result = $this->getParsedSectionOrText( $articleObj, $titleObj, $popts, $pageid ) ; |
103 | 105 | |
104 | | - } else { |
| 106 | + } else { // This is an old revision, so get the text differently |
105 | 107 | $text = $rev->getText( Revision::FOR_THIS_USER ); |
106 | 108 | |
107 | 109 | $wgTitle = $titleObj; |
— | — | @@ -121,6 +123,7 @@ |
122 | 124 | $this->dieUsageMsg( array( 'nosuchpageid', $pageid ) ); |
123 | 125 | } |
124 | 126 | } else { // $page |
| 127 | + |
125 | 128 | if ( $params['redirects'] ) { |
126 | 129 | $req = new FauxRequest( array( |
127 | 130 | 'action' => 'query', |
— | — | @@ -150,10 +153,10 @@ |
151 | 154 | $oldid = $articleObj->getRevIdFetched(); |
152 | 155 | } |
153 | 156 | |
154 | | - $p_result = $this->getParsedSectionOrText( $articleObj, $titleObj, $text, $popts, $pageid ) ; |
| 157 | + $p_result = $this->getParsedSectionOrText( $articleObj, $titleObj, $popts, $pageid ) ; |
155 | 158 | } |
156 | 159 | |
157 | | - } else { // Not $oldid, $pageid, $page |
| 160 | + } else { // Not $oldid, $pageid, $page. Hence based on $text |
158 | 161 | |
159 | 162 | $titleObj = Title::newFromText( $title ); |
160 | 163 | if ( !$titleObj ) { |
— | — | @@ -289,16 +292,15 @@ |
290 | 293 | /** |
291 | 294 | * @param $articleObj Article |
292 | 295 | * @param $titleObj Title |
| 296 | + * @param $popts ParserOptions |
293 | 297 | * @param $pageId Int |
294 | | - * @param $text String |
295 | | - * @param $popts ParserOptions |
296 | 298 | * @return ParserOutput |
297 | 299 | */ |
298 | | - private function getParsedSectionOrText( $articleObj, $titleObj, $text, $popts, $pageId = null ) { |
299 | | - global $wgParser; |
| 300 | + private function getParsedSectionOrText( $articleObj, $titleObj, $popts, $pageId = null ) { |
| 301 | + if ( $this->section !== false ) { |
| 302 | + global $wgParser; |
300 | 303 | |
301 | | - if ( $this->section !== false ) { |
302 | | - $text = $this->getSectionText( $text, !is_null ( $pageId ) |
| 304 | + $text = $this->getSectionText( $articleObj->getRawText(), !is_null ( $pageId ) |
303 | 305 | ? 'page id ' . $pageId : $titleObj->getText() ); |
304 | 306 | |
305 | 307 | return $wgParser->parse( $text, $titleObj, $popts ); |