69 if ( !empty( $_GET[
"rs"] ) ) {
73 if ( !empty( $_POST[
"rs"] ) ) {
77 switch ( $this->mode ) {
79 $this->func_name = $_GET[
"rs"] ??
'';
80 if ( !empty( $_GET[
"rsargs"] ) ) {
81 $this->args = $_GET[
"rsargs"];
87 $this->func_name = $_POST[
"rs"] ??
'';
88 if ( !empty( $_POST[
"rsargs"] ) ) {
89 $this->args = $_POST[
"rsargs"];
96 # Or we could throw an exception:
97 # throw new MWException( __METHOD__ . ' called without any data (mode empty).' );
113 if ( empty( $this->mode ) ) {
117 $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
118 if ( !in_array( $this->func_name, $this->config->get(
'AjaxExportList' ) ) ) {
119 wfDebug( __METHOD__ .
' Bad Request for unknown function ' . $this->func_name .
"\n" );
123 "unknown function " . $this->func_name
125 } elseif ( !$permissionManager->isEveryoneAllowed(
'read' ) &&
126 !$permissionManager->userHasRight( $user,
'read' ) ) {
130 'You are not allowed to view pages.' );
132 wfDebug( __METHOD__ .
' dispatching ' . $this->func_name .
"\n" );
134 $result = call_user_func_array( $this->func_name, $this->args );
136 if ( $result ===
false || $result ===
null ) {
137 wfDebug( __METHOD__ .
' ERROR while dispatching ' .
138 $this->func_name .
"(" . var_export( $this->args,
true ) .
"): " .
139 "no data returned\n" );
142 "{$this->func_name} returned no data" );
144 if ( is_string( $result ) ) {
149 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
150 $lbFactory->commitMasterChanges( __METHOD__ );
152 $result->sendHeaders();
153 $result->printText();
155 wfDebug( __METHOD__ .
' dispatch complete for ' . $this->func_name .
"\n" );
157 }
catch ( Exception $e ) {
158 wfDebug( __METHOD__ .
' ERROR while dispatching ' .
159 $this->func_name .
"(" . var_export( $this->args,
true ) .
"): " .
160 get_class( $e ) .
": " . $e->getMessage() .
"\n" );
162 if ( !headers_sent() ) {
166 print $e->getMessage();
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,...
while(( $__line=Maintenance::readconsole()) !==false) print
Interface for configuration instances.