Merge "Revert "Use display name in category page subheadings if provided""
[lhc/web/wiklou.git] / includes / AjaxDispatcher.php
index b14114d..d444a27 100644 (file)
@@ -74,7 +74,7 @@ class AjaxDispatcher {
                                if ( !empty( $_GET["rsargs"] ) ) {
                                        $this->args = $_GET["rsargs"];
                                } else {
-                                       $this->args = array();
+                                       $this->args = [];
                                }
                                break;
                        case 'post':
@@ -82,7 +82,7 @@ class AjaxDispatcher {
                                if ( !empty( $_POST["rsargs"] ) ) {
                                        $this->args = $_POST["rsargs"];
                                } else {
-                                       $this->args = array();
+                                       $this->args = [];
                                }
                                break;
                        default:
@@ -90,7 +90,6 @@ class AjaxDispatcher {
                                # Or we could throw an exception:
                                # throw new MWException( __METHOD__ . ' called without any data (mode empty).' );
                }
-
        }
 
        /**
@@ -124,9 +123,9 @@ class AjaxDispatcher {
                                $result = call_user_func_array( $this->func_name, $this->args );
 
                                if ( $result === false || $result === null ) {
-                                       wfDebug( __METHOD__ . ' ERROR while dispatching '
-                                                       . $this->func_name . "(" . var_export( $this->args, true ) . "): "
-                                                       . "no data returned\n" );
+                                       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" );
@@ -135,15 +134,18 @@ class AjaxDispatcher {
                                                $result = new AjaxResponse( $result );
                                        }
 
+                                       // Make sure DB commit succeeds before sending a response
+                                       wfGetLBFactory()->commitMasterChanges( __METHOD__ );
+
                                        $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" );
+                               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',
@@ -153,6 +155,5 @@ class AjaxDispatcher {
                                }
                        }
                }
-
        }
 }