X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FAjaxDispatcher.php;h=d444a2791f36413527febbd2fcea7e1625478849;hp=b14114d76b93838bc57519932a75e6f7727a7c86;hb=7874fc4bec845ad92960b07e969c65f3c3fe74f2;hpb=badc035712ded02e8ec7ee4c5e8a0fe09e2811d2 diff --git a/includes/AjaxDispatcher.php b/includes/AjaxDispatcher.php index b14114d76b..d444a2791f 100644 --- a/includes/AjaxDispatcher.php +++ b/includes/AjaxDispatcher.php @@ -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 { } } } - } }