function raven_requirements in Raven: Sentry Integration 7.2
Same name and namespace in other branches
- 8.2 raven.install \raven_requirements()
- 8 raven.install \raven_requirements()
- 7.4 raven.install \raven_requirements()
- 7 raven.install \raven_requirements()
- 7.3 raven.install \raven_requirements()
- 3.x raven.install \raven_requirements()
Implements hook_requirements().
File
- ./
raven.install, line 60 - Install, update, and uninstall functions for the Raven module.
Code
function raven_requirements($phase) {
$t = get_t();
$requirements = array();
$url = 'https://github.com/getsentry/sentry-php/releases';
$has_curl = function_exists('curl_init');
$requirements['raven_curl'] = array(
'title' => $t('cURL'),
'value' => $has_curl ? $t('Enabled') : $t('Not found'),
);
if (!$has_curl) {
$requirements['raven_curl']['severity'] = REQUIREMENT_ERROR;
$requirements['raven_curl']['description'] = $t('Raven module could not be installed because the PHP <a href="@curl_url">cURL</a> extension is not available.', array(
'@curl_url' => 'http://php.net/manual/en/curl.setup.php',
));
}
switch ($phase) {
case 'runtime':
$raven = [];
if (class_exists('Raven_Client')) {
$raven['loaded'] = TRUE;
$raven['version'] = Raven_Client::VERSION;
}
elseif (module_exists('libraries')) {
$raven = libraries_load('sentry-php');
}
if ($raven && $raven['loaded']) {
if (version_compare($raven['version'], 2, '<')) {
$requirements['raven_version'] = array(
'title' => $t('Sentry PHP library'),
'value' => $raven['version'],
'description' => $t('To check for newer versions of Sentry PHP, go to <a href="@url" rel="noreferrer" target="_blank">@url</a>.', array(
'@url' => $url,
)),
'severity' => REQUIREMENT_OK,
);
}
else {
$requirements['raven_version'] = array(
'title' => $t('Sentry PHP library'),
'value' => $raven['version'],
'description' => $t('Please install version 1.x of the <a href="@url" rel="noreferrer" target="_blank">Sentry PHP library</a>.', array(
'@url' => $url,
)),
'severity' => REQUIREMENT_ERROR,
);
}
if (!variable_get('raven_enabled', FALSE)) {
$requirements['raven_enabled'] = array(
'title' => $t('Sentry logging'),
'value' => $t('Disabled'),
'description' => $t('Sentry logging is disabled.'),
'severity' => REQUIREMENT_WARNING,
);
}
elseif (empty($_SERVER['SENTRY_DSN']) && !variable_get('raven_dsn', '')) {
$requirements['raven_dsn'] = array(
'title' => $t('Sentry logging'),
'value' => $t('Disabled'),
'description' => $t('Sentry logging is enabled but Sentry DSN is not set.'),
'severity' => REQUIREMENT_WARNING,
);
}
else {
$requirements['raven_dsn'] = array(
'title' => $t('Sentry logging'),
'value' => $t('Enabled'),
'description' => $t('Sentry is set to log to %dsn.', array(
'%dsn' => empty($_SERVER['SENTRY_DSN']) ? variable_get('raven_dsn', '') : $_SERVER['SENTRY_DSN'],
)),
'severity' => REQUIREMENT_OK,
);
if (variable_get('raven_trace', FALSE)) {
$requirements['raven_trace'] = array(
'title' => $t('Sentry reflection tracing'),
'value' => $t('Enabled'),
'description' => $t('Sentry reflection tracing is enabled, which results in sensitive data being logged by Sentry.'),
'severity' => REQUIREMENT_WARNING,
);
}
else {
$requirements['raven_trace'] = array(
'title' => $t('Sentry reflection tracing'),
'value' => $t('Disabled'),
'description' => $t('Sentry reflection tracing is disabled.'),
'severity' => REQUIREMENT_OK,
);
}
}
if ($client = raven_get_client()) {
if ($client->environment) {
$requirements['raven_environment'] = array(
'title' => $t('Sentry environment'),
'value' => check_plain($client->environment),
'severity' => REQUIREMENT_OK,
);
}
if ($client->release) {
$requirements['raven_release'] = array(
'title' => $t('Sentry release'),
'value' => check_plain($client->release),
'severity' => REQUIREMENT_OK,
);
}
}
}
else {
$requirements['sentry_library'] = array(
'title' => $t('Sentry PHP library'),
'value' => $t('Not installed'),
'description' => $t('The Sentry PHP library could not be loaded. Please install version 1.x of the <a href="@url" rel="noreferrer" target="_blank">Sentry PHP library</a> either via composer (into your vendor directory), or using libraries and xautoload modules (as <em>sites/all/libraries/sentry-php</em>). For instructions see the Raven module README.md file.', array(
'@url' => $url,
)),
'severity' => REQUIREMENT_ERROR,
);
}
break;
default:
break;
}
return $requirements;
}