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).' );
110 if ( empty( $this->mode ) ) {
114 $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
115 if ( !in_array( $this->func_name, $this->config->get(
'AjaxExportList' ) ) ) {
116 wfDebug( __METHOD__ .
' Bad Request for unknown function ' . $this->func_name );
120 "unknown function " . $this->func_name
122 } elseif ( !$permissionManager->isEveryoneAllowed(
'read' ) &&
123 !$permissionManager->userHasRight( $user,
'read' )
128 'You are not allowed to view pages.' );
130 wfDebug( __METHOD__ .
' dispatching ' . $this->func_name );
132 $result = call_user_func_array( $this->func_name, $this->args );
134 if ( $result ===
false || $result ===
null ) {
135 wfDebug( __METHOD__ .
' ERROR while dispatching ' .
136 $this->func_name .
"(" . var_export( $this->args,
true ) .
"): " .
137 "no data returned" );
140 "{$this->func_name} returned no data" );
142 if ( is_string( $result ) ) {
147 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
148 $lbFactory->commitPrimaryChanges( __METHOD__ );
150 $result->sendHeaders();
151 $result->printText();
153 wfDebug( __METHOD__ .
' dispatch complete for ' . $this->func_name );
155 }
catch ( Exception $e ) {
156 wfDebug( __METHOD__ .
' ERROR while dispatching ' .
157 $this->func_name .
"(" . var_export( $this->args,
true ) .
"): " .
158 get_class( $e ) .
": " . $e->getMessage() );
160 if ( !headers_sent() ) {
164 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.
array $args
Arguments passed.
string $mode
The way the request was made, either a 'get' or a 'post'.
__construct(Config $config)
Load up our object with user supplied data.
string $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.