* API: Enabled output caching to allow proper output format in case of an error.
authorYuri Astrakhan <yurik@users.mediawiki.org>
Fri, 13 Oct 2006 05:21:38 +0000 (05:21 +0000)
committerYuri Astrakhan <yurik@users.mediawiki.org>
Fri, 13 Oct 2006 05:21:38 +0000 (05:21 +0000)
includes/api/ApiMain.php
includes/api/ApiQueryAllpages.php

index 0b3f6ab..a12a159 100644 (file)
@@ -94,8 +94,13 @@ class ApiMain extends ApiBase {
 
        public function execute() {
                $this->profileIn();
-               $action = $format = $version = null;
+
+               // Experimental -- in case an error occurs during data output,
+               // this clear the output buffer and print just the error information
+               ob_start();
+
                try {
+                       $action = $format = $version = null;
                        extract($this->extractRequestParams());
                        $this->mShowVersions = $version;
 
@@ -112,6 +117,8 @@ class ApiMain extends ApiBase {
                } catch (UsageException $e) {
                        $this->printError();
                }
+               
+               ob_end_flush();
                $this->profileOut();
        }
 
@@ -133,6 +140,10 @@ class ApiMain extends ApiBase {
                // Printer may not be initialized if the extractRequestParams() fails for the main module
                if (!isset ($this->mPrinter))
                        $this->mPrinter = new $this->mFormats[API_DEFAULT_FORMAT] ($this, API_DEFAULT_FORMAT);
+               
+               // In case of an error, reset anythnig that was printed before
+               ob_clean();
+               
                $this->printResult(true);
        }
 
index dc7758b..e02b459 100644 (file)
@@ -161,8 +161,8 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
        protected function getExamples() {
                return array (
                        'Simple Use',
-                       '  api.php?action=query&list=allpages',
-                       '  api.php?action=query&list=allpages&apfrom=B&aplimit=5',
+                       ' Show a list of pages starting at the letter "B"',
+                       '  api.php?action=query&list=allpages&apfrom=B',
                        'Using as Generator',
                        ' Show info about 4 pages starting at the letter "T"',
                        '  api.php?action=query&generator=allpages&gaplimit=4&gapfrom=T&prop=info',