Update git submodules
[lhc/web/wiklou.git] / includes / AjaxDispatcher.php
index 96892d7..75fcff3 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup Ajax
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * @defgroup Ajax Ajax
  */
@@ -54,6 +56,7 @@ class AjaxDispatcher {
 
        /**
         * Load up our object with user supplied data
+        * @param Config $config
         */
        function __construct( Config $config ) {
                $this->config = $config;
@@ -74,7 +77,7 @@ class AjaxDispatcher {
                                if ( !empty( $_GET["rsargs"] ) ) {
                                        $this->args = $_GET["rsargs"];
                                } else {
-                                       $this->args = array();
+                                       $this->args = [];
                                }
                                break;
                        case 'post':
@@ -82,7 +85,7 @@ class AjaxDispatcher {
                                if ( !empty( $_POST["rsargs"] ) ) {
                                        $this->args = $_POST["rsargs"];
                                } else {
-                                       $this->args = array();
+                                       $this->args = [];
                                }
                                break;
                        default:
@@ -90,7 +93,6 @@ class AjaxDispatcher {
                                # Or we could throw an exception:
                                # throw new MWException( __METHOD__ . ' called without any data (mode empty).' );
                }
-
        }
 
        /**
@@ -135,6 +137,10 @@ class AjaxDispatcher {
                                                $result = new AjaxResponse( $result );
                                        }
 
+                                       // Make sure DB commit succeeds before sending a response
+                                       $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+                                       $lbFactory->commitMasterChanges( __METHOD__ );
+
                                        $result->sendHeaders();
                                        $result->printText();
 
@@ -153,6 +159,5 @@ class AjaxDispatcher {
                                }
                        }
                }
-
        }
 }