public static function Redis_Client::getGlobalPrefix in Redis 7.3
Get site default global prefix
Return value
string
1 call to Redis_Client::getGlobalPrefix()
- Redis_Client::getDefaultPrefix in lib/
Redis/ Client.php - Get global default prefix
File
- lib/
Redis/ Client.php, line 58
Class
- Redis_Client
- This static class only reason to exist is to tie Drupal global configuration to OOP driven code of this module: it will handle everything that must be read from global configuration and let other components live without any existence of it
Code
public static function getGlobalPrefix() {
// Provide a fallback for multisite. This is on purpose not inside the
// getPrefixForBin() function in order to decouple the unified prefix
// variable logic and custom module related security logic, that is not
// necessary for all backends. We can't just use HTTP_HOST, as multiple
// hosts might be using the same database. Or, more commonly, a site
// might not be a multisite at all, but might be using Drush leading to
// a separate HTTP_HOST of 'default'. Likewise, we can't rely on
// conf_path(), as settings.php might be modifying what database to
// connect to. To mirror what core does with database caching we use
// the DB credentials to inform our cache key.
if (null === self::$globalPrefix) {
if (isset($GLOBALS['db_url']) && is_string($GLOBALS['db_url'])) {
// Drupal 6 specifics when using the cache_backport module, we
// therefore cannot use \Database class to determine database
// settings.
self::$globalPrefix = md5($GLOBALS['db_url']);
}
else {
require_once DRUPAL_ROOT . '/includes/database/database.inc';
$dbInfo = Database::getConnectionInfo();
$active = $dbInfo['default'];
self::$globalPrefix = md5($active['host'] . $active['database'] . $active['prefix']['default']);
}
}
return self::$globalPrefix;
}