public function testGetRequestForAsyncJob()
 {
     if (version_compare($GLOBALS['wgVersion'], '1.20', '<')) {
         $this->markTestSkipped("Skipping test because of missing method");
     }
     $request = array();
     $instance = new SpecialDeferredRequestDispatcher();
     $instance->disallowToModifyHttpHeader();
     $instance->getContext()->setRequest(new \FauxRequest($request, false));
     $this->assertNull($instance->execute(''));
 }
 private function doPostJobWith($type, $title, $parameters, $dispatchableCallbackJob)
 {
     // Build requestToken as source verification during the POST request
     $parameters['timestamp'] = time();
     $parameters['requestToken'] = SpecialDeferredRequestDispatcher::getRequestToken($parameters['timestamp']);
     $parameters['async-job'] = array('type' => $type, 'title' => $title->getPrefixedDBkey());
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_METHOD, 'POST');
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_CONTENT_TYPE, "application/x-www-form-urlencoded");
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_CONTENT, 'parameters=' . json_encode($parameters));
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_CONNECTION_FAILURE_REPEAT, 2);
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_ON_COMPLETED_CALLBACK, function ($requestResponse) use($parameters) {
         $requestResponse->set('type', $parameters['async-job']['type']);
         $requestResponse->set('title', $parameters['async-job']['title']);
         wfDebugLog('smw', 'SMW\\DeferredRequestDispatchManager: ' . json_encode($requestResponse->getList(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "\n");
     });
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_ON_FAILED_CALLBACK, function ($requestResponse) use($dispatchableCallbackJob, $title, $type, $parameters) {
         $requestResponse->set('type', $parameters['async-job']['type']);
         $requestResponse->set('title', $parameters['async-job']['title']);
         wfDebugLog('smw', "SMW\\DeferredRequestDispatchManager: Connection to SpecialDeferredRequestDispatcher failed on {$type} with " . json_encode($requestResponse->getList(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . " " . $title->getPrefixedDBkey() . "\n");
         call_user_func_array($dispatchableCallbackJob, array($title, $parameters));
     });
     $this->httpRequest->execute();
     return true;
 }
 /**
  * @since 2.3
  *
  * @param string $type
  * @param Title $title
  * @param array $parameters
  */
 public function dispatchJobRequestFor($type, Title $title, $parameters = array())
 {
     if (!$this->doPreliminaryCheckForType($type, $parameters)) {
         return null;
     }
     $dispatchableCallbackJob = $this->getDispatchableCallbackJobFor($type);
     // Build sessionToken as source verification during the POST request
     $parameters['timestamp'] = time();
     $parameters['sessionToken'] = SpecialDeferredRequestDispatcher::getSessionToken($parameters['timestamp']);
     if ($this->enabledHttpDeferredJobRequestState && $this->canConnectToUrl()) {
         return $this->doDispatchAsyncJobFor($type, $title, $parameters, $dispatchableCallbackJob);
     }
     call_user_func_array($dispatchableCallbackJob, array($title, $parameters));
     return true;
 }
 /**
  * @since 2.3
  *
  * @param string $type
  * @param Title $title
  * @param array $parameters
  */
 public function dispatchJobRequestFor($type, Title $title, $parameters = array())
 {
     $this->httpRequest->setOption(ONOI_HTTP_REQUEST_URL, SpecialDeferredRequestDispatcher::getTargetURL());
     if (!$this->doPreliminaryCheckForType($type, $parameters)) {
         return null;
     }
     $dispatchableCallbackJob = $this->getDispatchableCallbackJobFor($type);
     // Build requestToken as source verification during the POST request
     $parameters['timestamp'] = time();
     $parameters['requestToken'] = SpecialDeferredRequestDispatcher::getRequestToken($parameters['timestamp']);
     if ($this->enabledHttpDeferredJobRequestState && $this->canConnectToUrl()) {
         return $this->doPostJobWith($type, $title, $parameters, $dispatchableCallbackJob);
     }
     call_user_func_array($dispatchableCallbackJob, array($title, $parameters));
     return true;
 }