Beispiel #1
0
 function performAction()
 {
     global $wgAjaxExportList, $wgOut;
     if (empty($this->mode)) {
         return;
     }
     wfProfileIn('AjaxDispatcher::performAction');
     if (!in_array($this->func_name, $wgAjaxExportList)) {
         header('Status: 400 Bad Request', true, 400);
         print "unknown function " . htmlspecialchars((string) $this->func_name);
     } else {
         try {
             $result = call_user_func_array($this->func_name, $this->args);
             if ($result === false || $result === NULL) {
                 header('Status: 500 Internal Error', true, 500);
                 echo "{$this->func_name} returned no data";
             } else {
                 if (is_string($result)) {
                     $result = new AjaxResponse($result);
                 }
                 $result->sendHeaders();
                 $result->printText();
             }
         } catch (Exception $e) {
             if (!headers_sent()) {
                 header('Status: 500 Internal Error', true, 500);
                 print $e->getMessage();
             } else {
                 print $e->getMessage();
             }
         }
     }
     wfProfileOut('AjaxDispatcher::performAction');
     $wgOut = null;
 }
Beispiel #2
0
 function performAction()
 {
     global $wgAjaxExportList, $wgOut;
     if (empty($this->mode)) {
         return;
     }
     wfProfileIn(__METHOD__);
     if (!in_array($this->func_name, $wgAjaxExportList)) {
         wfHttpError(400, 'Bad Request', "unknown function " . (string) $this->func_name);
     } else {
         try {
             $result = call_user_func_array($this->func_name, $this->args);
             if ($result === false || $result === NULL) {
                 wfHttpError(500, 'Internal Error', "{$this->func_name} returned no data");
             } else {
                 if (is_string($result)) {
                     $result = new AjaxResponse($result);
                 }
                 $result->sendHeaders();
                 $result->printText();
             }
         } catch (Exception $e) {
             if (!headers_sent()) {
                 wfHttpError(500, 'Internal Error', $e->getMessage());
             } else {
                 print $e->getMessage();
             }
         }
     }
     wfProfileOut(__METHOD__);
     $wgOut = null;
 }
Beispiel #3
0
 /** Pass the request to our internal function.
  * BEWARE! Data are passed as they have been supplied by the user,
  * they should be carefully handled in the function processing the
  * request.
  */
 function performAction()
 {
     global $wgAjaxExportList, $wgOut, $wgUser;
     if (empty($this->mode)) {
         return;
     }
     /*
      * Wikia Change - begin
      */
     Transaction::setEntryPoint(Transaction::ENTRY_POINT_AJAX);
     Transaction::setAttribute(Transaction::PARAM_FUNCTION, $this->func_name);
     if (function_exists('newrelic_disable_autorum')) {
         newrelic_disable_autorum();
     }
     /*
      * Wikia Change - end
      */
     wfProfileIn(__METHOD__);
     if (!in_array($this->func_name, $wgAjaxExportList)) {
         wfDebug(__METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n");
         wfHttpError(400, 'Bad Request', "unknown function " . (string) $this->func_name);
     } elseif (!in_array('read', User::getGroupPermissions(array('*')), true) && !$wgUser->isAllowed('read')) {
         wfHttpError(403, 'Forbidden', 'You must log in to view pages.');
     } else {
         wfDebug(__METHOD__ . ' dispatching ' . $this->func_name . "\n");
         if (strpos($this->func_name, '::') !== false) {
             $func = explode('::', $this->func_name, 2);
         } else {
             $func = $this->func_name;
         }
         try {
             $result = call_user_func_array($func, $this->args);
             if ($result === false || $result === null) {
                 wfDebug(__METHOD__ . ' ERROR while dispatching ' . $this->func_name . "(" . var_export($this->args, true) . "): " . "no data returned\n");
                 /* Wikia changes start */
                 //let's avoid falling back to Iowa (500, 503) in this case,
                 //probably someone is asking for a non-existing dynamic method name
                 wfHttpError(501, 'Not Implemented', "{$this->func_name} returned no data");
             } else {
                 if (is_string($result)) {
                     $result = new AjaxResponse($result);
                 }
                 $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");
             if (!headers_sent()) {
                 wfHttpError(500, 'Internal Error', $e->getMessage());
             } else {
                 print $e->getMessage();
             }
         }
     }
     $wgOut = null;
     wfProfileOut(__METHOD__);
 }
Beispiel #4
0
 /** Pass the request to our internal function.
  * BEWARE! Data are passed as they have been supplied by the user,
  * they should be carefully handled in the function processing the
  * request.
  */
 function performAction()
 {
     global $wgAjaxExportList, $wgOut;
     if (empty($this->mode)) {
         return;
     }
     wfProfileIn(__METHOD__);
     if (!in_array($this->func_name, $wgAjaxExportList)) {
         wfDebug(__METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n");
         wfHttpError(400, 'Bad Request', "unknown function " . (string) $this->func_name);
     } else {
         wfDebug(__METHOD__ . ' dispatching ' . $this->func_name . "\n");
         if (strpos($this->func_name, '::') !== false) {
             $func = explode('::', $this->func_name, 2);
         } else {
             $func = $this->func_name;
         }
         try {
             $result = call_user_func_array($func, $this->args);
             if ($result === false || $result === NULL) {
                 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");
             } else {
                 if (is_string($result)) {
                     $result = new AjaxResponse($result);
                 }
                 $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");
             if (!headers_sent()) {
                 wfHttpError(500, 'Internal Error', $e->getMessage());
             } else {
                 print $e->getMessage();
             }
         }
     }
     wfProfileOut(__METHOD__);
     $wgOut = null;
 }
 /** Pass the request to our internal function.
  * BEWARE! Data are passed as they have been supplied by the user,
  * they should be carefully handled in the function processing the
  * request.
  */
 function performAction()
 {
     global $wgAjaxExportList;
     if (empty($this->mode)) {
         return;
     }
     if (!in_array($this->func_name, $wgAjaxExportList)) {
         header("HTTP/1.0 400 Bad Request");
         header("Status: 400 Bad Request");
         header('Content-type: text/html; charset=utf-8');
         print "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">" . "<html><head><title>" . htmlspecialchars("Bad Request") . "</title></head><body><h1>" . htmlspecialchars("Bad Request") . "</h1><p>" . nl2br(htmlspecialchars("unknown function " . (string) $this->func_name)) . "</p></body></html>\n";
     } else {
         if (strpos($this->func_name, '::') !== false) {
             $func = explode('::', $this->func_name, 2);
         } else {
             $func = $this->func_name;
         }
         try {
             $result = call_user_func_array($func, $this->args);
             if ($result === false || $result === NULL) {
             } else {
                 if (is_string($result)) {
                     $result = new AjaxResponse($result);
                 }
                 if ($this->contentType) {
                     $result->setContentType($this->contentType);
                 }
                 $result->sendHeaders($this->expire, $this->contentType);
                 $result->printText();
             }
         } catch (Exception $e) {
             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', $e->getMessage());
             } else {
                 print $e->getMessage();
             }
         }
     }
 }
 /**
  * Pass the request to our internal function.
  * BEWARE! Data are passed as they have been supplied by the user,
  * they should be carefully handled in the function processing the
  * request.
  *
  * @param User $user
  */
 function performAction(User $user)
 {
     if (empty($this->mode)) {
         return;
     }
     if (!in_array($this->func_name, $this->config->get('AjaxExportList'))) {
         wfDebug(__METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n");
         wfHttpError(400, 'Bad Request', "unknown function " . $this->func_name);
     } elseif (!User::isEveryoneAllowed('read') && !$user->isAllowed('read')) {
         wfHttpError(403, 'Forbidden', 'You are not allowed to view pages.');
     } else {
         wfDebug(__METHOD__ . ' dispatching ' . $this->func_name . "\n");
         try {
             $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");
                 wfHttpError(500, 'Internal Error', "{$this->func_name} returned no data");
             } else {
                 if (is_string($result)) {
                     $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");
             if (!headers_sent()) {
                 wfHttpError(500, 'Internal Error', $e->getMessage());
             } else {
                 print $e->getMessage();
             }
         }
     }
 }
 /**
  * Pass the request to our internal function.
  * BEWARE! Data are passed as they have been supplied by the user,
  * they should be carefully handled in the function processing the
  * request.
  */
 function performAction()
 {
     global $wgAjaxExportList, $wgUser;
     if (empty($this->mode)) {
         return;
     }
     wfProfileIn(__METHOD__);
     if (!in_array($this->func_name, $wgAjaxExportList)) {
         wfDebug(__METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n");
         wfHttpError(400, 'Bad Request', "unknown function " . (string) $this->func_name);
     } elseif (!in_array('read', User::getGroupPermissions(array('*')), true) && !$wgUser->isAllowed('read')) {
         wfHttpError(403, 'Forbidden', 'You must log in to view pages.');
     } else {
         wfDebug(__METHOD__ . ' dispatching ' . $this->func_name . "\n");
         try {
             $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");
                 wfHttpError(500, 'Internal Error', "{$this->func_name} returned no data");
             } else {
                 if (is_string($result)) {
                     $result = new AjaxResponse($result);
                 }
                 $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");
             if (!headers_sent()) {
                 wfHttpError(500, 'Internal Error', $e->getMessage());
             } else {
                 print $e->getMessage();
             }
         }
     }
     wfProfileOut(__METHOD__);
 }