From d81f562b712f2387fa02290bf2ca86392ab356f2 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 11 Oct 2006 20:21:25 +0000 Subject: Aktualisierung auf Version 1.8.1 --- includes/AjaxDispatcher.php | 60 +++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 26 deletions(-) (limited to 'includes/AjaxDispatcher.php') diff --git a/includes/AjaxDispatcher.php b/includes/AjaxDispatcher.php index 2084c366..618c2736 100644 --- a/includes/AjaxDispatcher.php +++ b/includes/AjaxDispatcher.php @@ -1,36 +1,22 @@ mode = ""; if (! empty($_GET["rs"])) { @@ -60,23 +46,45 @@ class AjaxDispatcher { } function performAction() { - global $wgAjaxCachePolicy, $wgAjaxExportList; + global $wgAjaxExportList, $wgOut; + if ( empty( $this->mode ) ) { return; } wfProfileIn( 'AjaxDispatcher::performAction' ); if (! in_array( $this->func_name, $wgAjaxExportList ) ) { - echo "-:{$this->func_name} not callable"; + header( 'Status: 400 Bad Request', true, 400 ); + echo "unknown function {$this->func_name}"; } else { - echo "+:"; - $result = call_user_func_array($this->func_name, $this->args); - header( 'Content-Type: text/html; charset=utf-8', true ); - $wgAjaxCachePolicy->writeHeader(); - echo $result; + try { + $result = call_user_func_array($this->func_name, $this->args); + + if ( $result === false || $result === NULL ) { + header( 'Status: 500 Internal Error', true, 500 ); + echo "{$this->func_name} returned no data"; + } + else { + if ( is_string( $result ) ) { + $result= new AjaxResponse( $result ); + } + + $result->sendHeaders(); + $result->printText(); + } + + } catch (Exception $e) { + if (!headers_sent()) { + header( 'Status: 500 Internal Error', true, 500 ); + print $e->getMessage(); + } else { + print $e->getMessage(); + } + } } + wfProfileOut( 'AjaxDispatcher::performAction' ); - exit; + $wgOut = null; } } -- cgit v1.2.2