66 if ( !empty( $_GET[
"rs"] ) ) {
70 if ( !empty( $_POST[
"rs"] ) ) {
74 switch ( $this->mode ) {
76 $this->func_name = isset( $_GET[
"rs"] ) ? $_GET[
"rs"] :
'';
77 if ( !empty( $_GET[
"rsargs"] ) ) {
78 $this->args = $_GET[
"rsargs"];
84 $this->func_name = isset( $_POST[
"rs"] ) ? $_POST[
"rs"] :
'';
85 if ( !empty( $_POST[
"rsargs"] ) ) {
86 $this->args = $_POST[
"rsargs"];
93 # Or we could throw an exception:
94 # throw new MWException( __METHOD__ . ' called without any data (mode empty).' );
107 if ( empty( $this->mode ) ) {
111 if ( !in_array( $this->func_name, $this->config->get(
'AjaxExportList' ) ) ) {
112 wfDebug( __METHOD__ .
' Bad Request for unknown function ' . $this->func_name .
"\n" );
116 "unknown function " . $this->func_name
118 } elseif ( !User::isEveryoneAllowed(
'read' ) && !$user->isAllowed(
'read' ) ) {
122 'You are not allowed to view pages.' );
124 wfDebug( __METHOD__ .
' dispatching ' . $this->func_name .
"\n" );
126 $result = call_user_func_array( $this->func_name, $this->args );
128 if ( $result ===
false || $result ===
null ) {
129 wfDebug( __METHOD__ .
' ERROR while dispatching ' .
130 $this->func_name .
"(" . var_export( $this->args,
true ) .
"): " .
131 "no data returned\n" );
134 "{$this->func_name} returned no data" );
136 if ( is_string( $result ) ) {
141 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
142 $lbFactory->commitMasterChanges( __METHOD__ );
144 $result->sendHeaders();
145 $result->printText();
147 wfDebug( __METHOD__ .
' dispatch complete for ' . $this->func_name .
"\n" );
149 }
catch ( Exception
$e ) {
150 wfDebug( __METHOD__ .
' ERROR while dispatching ' .
151 $this->func_name .
"(" . var_export( $this->args,
true ) .
"): " .
152 get_class(
$e ) .
": " .
$e->getMessage() .
"\n" );
154 if ( !headers_sent() ) {
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfHttpError( $code, $label, $desc)
Provide a simple HTTP error.
Object-Oriented Ajax functions.
$mode
The way the request was made, either a 'get' or a 'post'.
__construct(Config $config)
Load up our object with user supplied data.
$func_name
Name of the requested handler.
performAction(User $user)
Pass the request to our internal function.
Handle responses for Ajax requests (send headers, print content, that sort of thing)
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
returning false will NOT prevent logging $e