From: Roan Kattouw Date: Thu, 3 Jun 2010 09:53:28 +0000 (+0000) Subject: Fixed for r58099 per CR: X-Git-Tag: 1.31.0-rc.0~36629 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=2c14858bb8abebdad8a1ad41cbd27ea3042eb9c2;p=lhc%2Fweb%2Fwiklou.git Fixed for r58099 per CR: * Only clicktrack local, domain-relative URLs * Validate redirect URL in ApiClickTracking with the same condition used in ClickTracking.js (local, domain-relative) * Remove call to nonexistent function OutputPage::enable() * Add functionality for disabling API output and use this after setting up the redirect. This fixes the issue where the body of the redirect contained an API response in xmlfm form at; the body is now empty. --- diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index 3ad1419d70..d8bd510f6c 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -36,7 +36,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { abstract class ApiFormatBase extends ApiBase { private $mIsHtml, $mFormat, $mUnescapeAmps, $mHelp, $mCleared; - private $mBufferResult = false, $mBuffer; + private $mBufferResult = false, $mBuffer, $mDisabled = false; /** * Constructor @@ -113,6 +113,18 @@ abstract class ApiFormatBase extends ApiBase { return $this->getIsHtml(); } + /** + * Disable the formatter completely. This causes calls to initPrinter(), + * printText() and closePrinter() to be ignored. + */ + public function disable() { + $this->mDisabled = true; + } + + public function isDisabled() { + return $this->mDisabled; + } + /** * Initialize the printer function and prepare the output headers, etc. * This method must be the first outputing method during execution. @@ -120,6 +132,9 @@ abstract class ApiFormatBase extends ApiBase { * @param $isError bool Whether an error message is printed */ function initPrinter( $isError ) { + if ( $this->mDisabled ) { + return; + } $isHtml = $this->getIsHtml(); $mime = $isHtml ? 'text/html' : $this->getMimeType(); $script = wfScript( 'api' ); @@ -172,6 +187,9 @@ See complete documentation, or * Finish printing. Closes HTML tags. */ public function closePrinter() { + if ( $this->mDisabled ) { + return; + } if ( $this->getIsHtml() ) { ?> @@ -191,6 +209,9 @@ See complete documentation, or * @param $text string */ public function printText( $text ) { + if ( $this->mDisabled ) { + return; + } if ( $this->mBufferResult ) { $this->mBuffer = $text; } elseif ( $this->getIsHtml() ) { diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 49cee0af25..12f8a3ff43 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -199,6 +199,13 @@ class ApiMain extends ApiBase { public function getModule() { return $this->mModule; } + + /** + * Get the result formatter object. Only works after setupExecuteAction() + */ + public function getPrinter() { + return $this->mPrinter; + } /** * Only kept for backwards compatibility @@ -330,7 +337,7 @@ class ApiMain extends ApiBase { header( "Cache-Control: $ccHeader" ); - if ( $this->mPrinter->getIsHtml() ) { + if ( $this->mPrinter->getIsHtml() && !$this->mPrinter->isDisabled() ) { echo wfReportTime(); }