r79774 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79773‎ | r79774 | r79775 >
Date:23:35, 6 January 2011
Author:reedy
Status:ok
Tags:
Comment:
More tweaks/comments/fixups per r79455

ApiParse is a mess!
Modified paths:
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiParse.php
@@ -77,7 +77,9 @@
7878 $popts = new ParserOptions();
7979 $popts->setTidy( true );
8080 $popts->enableLimitReport( !$params['disablepp'] );
 81+
8182 $redirValues = null;
 83+
8284 if ( !is_null( $oldid ) || !is_null( $pageid ) || !is_null( $page ) ) {
8385
8486 if ( !is_null( $oldid ) ) {
@@ -98,9 +100,9 @@
99101 if ( $titleObj->getLatestRevID() === intval( $oldid ) ) {
100102 $articleObj = new Article( $titleObj, 0 );
101103
102 - $p_result = $this->getParsedSectionOrText( $articleObj, $titleObj, $articleObj->get, $popts, $pageid ) ;
 104+ $p_result = $this->getParsedSectionOrText( $articleObj, $titleObj, $popts, $pageid ) ;
103105
104 - } else {
 106+ } else { // This is an old revision, so get the text differently
105107 $text = $rev->getText( Revision::FOR_THIS_USER );
106108
107109 $wgTitle = $titleObj;
@@ -121,6 +123,7 @@
122124 $this->dieUsageMsg( array( 'nosuchpageid', $pageid ) );
123125 }
124126 } else { // $page
 127+
125128 if ( $params['redirects'] ) {
126129 $req = new FauxRequest( array(
127130 'action' => 'query',
@@ -150,10 +153,10 @@
151154 $oldid = $articleObj->getRevIdFetched();
152155 }
153156
154 - $p_result = $this->getParsedSectionOrText( $articleObj, $titleObj, $text, $popts, $pageid ) ;
 157+ $p_result = $this->getParsedSectionOrText( $articleObj, $titleObj, $popts, $pageid ) ;
155158 }
156159
157 - } else { // Not $oldid, $pageid, $page
 160+ } else { // Not $oldid, $pageid, $page. Hence based on $text
158161
159162 $titleObj = Title::newFromText( $title );
160163 if ( !$titleObj ) {
@@ -289,16 +292,15 @@
290293 /**
291294 * @param $articleObj Article
292295 * @param $titleObj Title
 296+ * @param $popts ParserOptions
293297 * @param $pageId Int
294 - * @param $text String
295 - * @param $popts ParserOptions
296298 * @return ParserOutput
297299 */
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;
300303
301 - if ( $this->section !== false ) {
302 - $text = $this->getSectionText( $text, !is_null ( $pageId )
 304+ $text = $this->getSectionText( $articleObj->getRawText(), !is_null ( $pageId )
303305 ? 'page id ' . $pageId : $titleObj->getText() );
304306
305307 return $wgParser->parse( $text, $titleObj, $popts );

Follow-up revisions

RevisionCommit summaryAuthorDate
r814071.17: MFT r79454, r79455, r79456, r79536, r79727, r79733, r79773, r79774, r80...catrope19:18, 2 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r79455Allow section to work with oldid when oldid == currentrevid (worked with olde...reedy23:01, 1 January 2011

Status & tagging log