* (bug 20336) changed json_decode json_encode to static class in global functions
[lhc/web/wiklou.git] / includes / AjaxDispatcher.php
index ca6f180..c489cf1 100644 (file)
@@ -1,5 +1,9 @@
 <?php
 /**
+ * @defgroup Ajax Ajax
+ *
+ * @file
+ * @ingroup Ajax
  * Handle ajax requests and send them to the proper handler.
  */
 
@@ -11,7 +15,7 @@ require_once( 'AjaxFunctions.php' );
 
 /**
  * Object-Oriented Ajax functions.
- * @addtogroup Ajax
+ * @ingroup Ajax
  */
 class AjaxDispatcher {
        /** The way the request was made, either a 'get' or a 'post' */
@@ -82,9 +86,13 @@ class AjaxDispatcher {
                wfProfileIn( __METHOD__ );
 
                if (! in_array( $this->func_name, $wgAjaxExportList ) ) {
+                       wfDebug( __METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n" );
+
                        wfHttpError( 400, 'Bad Request',
                                "unknown function " . (string) $this->func_name );
                } else {
+                       wfDebug( __METHOD__ . ' dispatching ' . $this->func_name . "\n" );
+
                        if ( strpos( $this->func_name, '::' ) !== false ) {
                                $func = explode( '::', $this->func_name, 2 );
                        } else {
@@ -94,6 +102,10 @@ class AjaxDispatcher {
                                $result = call_user_func_array($func, $this->args);
 
                                if ( $result === false || $result === NULL ) {
+                                       wfDebug( __METHOD__ . ' ERROR while dispatching ' 
+                                                       . $this->func_name . "(" . var_export( $this->args, true ) . "): " 
+                                                       . "no data returned\n" );
+
                                        wfHttpError( 500, 'Internal Error',
                                                "{$this->func_name} returned no data" );
                                }
@@ -104,9 +116,15 @@ class AjaxDispatcher {
 
                                        $result->sendHeaders();
                                        $result->printText();
+
+                                       wfDebug( __METHOD__ . ' dispatch complete for ' . $this->func_name . "\n" );
                                }
 
                        } catch (Exception $e) {
+                               wfDebug( __METHOD__ . ' ERROR while dispatching ' 
+                                               . $this->func_name . "(" . var_export( $this->args, true ) . "): " 
+                                               . get_class($e) . ": " . $e->getMessage() . "\n" );
+
                                if (!headers_sent()) {
                                        wfHttpError( 500, 'Internal Error',
                                                $e->getMessage() );