function _drd_get_lib in DRD Agent 7.3
Same name and namespace in other branches
- 6.3 drd_agent.module \_drd_get_lib()
Callback to download the DRD library if required,
Parameters
bool $force:
Throws
\Exception
4 calls to _drd_get_lib()
- drd_agent in ./
drd_agent.module - Menu callback to execute the remote request for an action.
- drd_agent_authorize_secret in ./
drd_agent.module - Menu callback to authorize a DRD instance by a secret.
- drd_agent_crypt in ./
drd_agent.module - Menu callback to return an array containing supported crypt methods.
- drd_agent_requirements in ./
drd_agent.install
File
- ./
drd_agent.module, line 69
Code
function _drd_get_lib($force = FALSE) {
$archive = 'drd-' . $_SERVER['HTTP_X_DRD_VERSION'] . '.phar';
$uri = 'temporary://' . $archive;
if ($force || !file_exists($uri)) {
$response = drupal_http_request(DRD_AGENT_LIB_BASE_URI . $archive);
if (empty($response->code) || $response->code != 200) {
throw new Exception('DRD Library not available');
}
file_put_contents($uri, $response->data);
}
require_once $uri;
if (!defined('DRD_BASE')) {
// Looks like loading the phar file failed. We've seen this on a Plesk and
// OpCache combination (@see https://www.drupal.org/node/2892316) and hence
// we try to disable opcache only for this request and load the phar again.
ini_set('opcache.enable', 0);
require $uri;
}
}