private function requestRestbase($method, $path, $params, $reqheaders = array()) { $request = array('method' => $method, 'url' => '/restbase/local/v1/' . $path); if ($method === 'GET') { $request['query'] = $params; } else { $request['body'] = $params; } $request['headers'] = $reqheaders; $response = $this->serviceClient->run($request); if ($response['code'] === 200 && $response['error'] === "") { // If response was served directly from Varnish, use the response // (RP) header to declare the cache hit and pass the data to the client. $headers = $response['headers']; $rp = null; if (isset($headers['x-cache']) && strpos($headers['x-cache'], 'hit') !== false) { $rp = 'cached-response=true'; } if ($rp !== null) { $resp = $this->getRequest()->response(); $resp->header('X-Cache: ' . $rp); } } elseif ($response['error'] !== '') { $this->dieUsage('docserver-http-error: ' . $response['error'], $response['error']); } else { // error null, code not 200 $this->dieUsage('docserver-http: HTTP ' . $response['code'], $response['code']); } return $response['body']; }
private function requestRestbase($method, $path, $params) { $request = array('method' => $method, 'url' => '/restbase/local/v1/' . $path); if ($method === 'GET') { $request['query'] = $params; } else { $request['body'] = $params; } $response = $this->serviceClient->run($request); if ($response['code'] === 200 && $response['error'] === '') { return $response['body']; } elseif ($response['error'] !== '') { $this->dieUsage('restbase-http-error: ' . $response['code'], $response['error']); } else { // error null, code not 200 $this->dieUsage('restbase-http: HTTP ' . $response['code'], $response['code']); } }
return \ObjectCache::newWANCacheFromParams($params); }, 'LocalServerObjectCache' => function (MediaWikiServices $services) { $mainConfig = $services->getMainConfig(); if (function_exists('apc_fetch')) { $id = 'apc'; } elseif (function_exists('apcu_fetch')) { $id = 'apcu'; } elseif (function_exists('xcache_get') && wfIniGetBool('xcache.var_size')) { $id = 'xcache'; } elseif (function_exists('wincache_ucache_get')) { $id = 'wincache'; } else { $id = CACHE_NONE; } if (!isset($mainConfig->get('ObjectCaches')[$id])) { throw new UnexpectedValueException("Cache type \"{$id}\" is not present in \$wgObjectCaches."); } return \ObjectCache::newFromParams($mainConfig->get('ObjectCaches')[$id]); }, 'VirtualRESTServiceClient' => function (MediaWikiServices $services) { $config = $services->getMainConfig()->get('VirtualRestConfig'); $vrsClient = new VirtualRESTServiceClient(new MultiHttpClient([])); foreach ($config['paths'] as $prefix => $serviceConfig) { $class = $serviceConfig['class']; // Merge in the global defaults $constructArg = isset($serviceConfig['options']) ? $serviceConfig['options'] : []; $constructArg += $config['global']; // Make the VRS service available at the mount point $vrsClient->mount($prefix, ['class' => $class, 'config' => $constructArg]); } return $vrsClient; }];