if ( !empty( $_GET["rsargs"] ) ) {
$this->args = $_GET["rsargs"];
} else {
- $this->args = array();
+ $this->args = [];
}
break;
case 'post':
if ( !empty( $_POST["rsargs"] ) ) {
$this->args = $_POST["rsargs"];
} else {
- $this->args = array();
+ $this->args = [];
}
break;
default:
# Or we could throw an exception:
# throw new MWException( __METHOD__ . ' called without any data (mode empty).' );
}
-
}
/**
$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" );
$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',
}
}
}
-
}
}