From bf6b004e1ae38198b0387d1c954270a2d408e26d Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Fri, 13 Oct 2006 05:21:38 +0000 Subject: [PATCH] * API: Enabled output caching to allow proper output format in case of an error. --- includes/api/ApiMain.php | 13 ++++++++++++- includes/api/ApiQueryAllpages.php | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 0b3f6abdc7..a12a1597ab 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -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); } diff --git a/includes/api/ApiQueryAllpages.php b/includes/api/ApiQueryAllpages.php index dc7758b40b..e02b459cc9 100644 --- a/includes/api/ApiQueryAllpages.php +++ b/includes/api/ApiQueryAllpages.php @@ -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', -- 2.20.1