/** * @return \Drupal\service_container\DependencyInjection\CachedContainerBuilder */ protected static function getContainerBuilder() { $service_provider_manager = new ServiceProviderPluginManager(); // This is an internal API, but we need the cache object. $cache = _cache_get_object('cache'); $container_builder = new CachedContainerBuilder($service_provider_manager, $cache); return $container_builder; }
/** * Instantiates a cache backend class for a given cache bin * * Classes implementing CacheBackendInterface can register * themselves both as a default implementation and for specific bins. * * @param string $bin * The cache bin for which a cache backend object should be returned. * * @return CacheBackendInterface * The cache backend object associated with the specified bin. */ public function get($bin) { return new CacheBackendProxy(_cache_get_object($bin)); }
/** * RateLimitPluginManager factory method. * * @param string $bin * The cache bin for the plugin manager. * * @return RateLimitPluginManager * The created manager. */ public static function create($bin = 'cache') { return new static(Module::getNamespaces(), _cache_get_object($bin)); }
define('DRUPAL_ROOT', substr($_SERVER['SCRIPT_FILENAME'], 0, strpos($_SERVER['SCRIPT_FILENAME'], $_SERVER['REQUEST_URI']))); // There's code, for example in phptemplate.engine, which assumes we're in the // Drupal root directory. chdir(DRUPAL_ROOT); require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; require_once DRUPAL_ROOT . '/includes/common.inc'; // Perform a minimal bootstrap. drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); drupal_add_http_header('X-Ad-bootstrap-phase', 'configuration'); // We'll try to load advertisement from the cache. require_once DRUPAL_ROOT . '/includes/cache.inc'; foreach (variable_get('cache_backends', array()) as $include) { require_once DRUPAL_ROOT . '/' . $include; } // Decide whether to bootstrap the database. $cache_backend = _cache_get_object('ad'); if ($cache_backend instanceof DrupalDatabaseCache) { drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE); drupal_add_http_header('X-Ad-bootstrap-phase', 'database'); } // Lock.inc could be used by cache backend (e.g. memcache stampede protection). require_once DRUPAL_ROOT . '/' . variable_get('lock_inc', 'includes/lock.inc'); // We use the queue API to store the impression. require_once DRUPAL_ROOT . '/modules/system/system.queue.inc'; // In my tests, including system.queue.inc directly is a lot faster than // module_load_include(); this also makes sure that module_implements() does not // exist, and therefore if watchdog() (or any other function that calls // module_implements()) is called, the cache of module_implements() is not // saved. //require_once DRUPAL_ROOT . '/includes/module.inc'; //module_load_include('inc', 'system', 'system.queue');
/** * Returns a checksum that indicates whether the 'system' table was modified. It is not required to be 100% * accurate, its goal is to not return the whole 'system' table in the response if the content did not change. * * @return string|null 32-character checksum value or NULL if the checksum is not supported. */ private function getExtensionChecksum() { // There are multiple ways to check when the 'system' table was updated. if (_cache_get_object('cache_bootstrap') instanceof DrupalDatabaseCache) { // Every time a "system" change is detected by Drupal, system_list_reset() gets called, which clears the // 'system_list' cache entry from the 'cache_bootstrap' cache bin. Right here we will check when the cache // entry was last recreated and use that as the checksum. $cacheRecreatedAt = $this->connection->query('SELECT created FROM {cache_bootstrap} WHERE cid = :cid', array(':cid' => 'system_list'))->fetchField(); if (ctype_digit((string) $cacheRecreatedAt)) { // Only rely on this check if we actually get a valid numeric timestamp. return md5($cacheRecreatedAt); } } if ($this->connection->databaseType() === 'mysql') { // https://dev.mysql.com/doc/refman/5.0/en/checksum-table.html $checksum = $this->connection->query('CHECKSUM TABLE {system}')->fetchField(1); // The columns returned are 'Table' (eg. schema.system) and 'Checksum' (numeric value, eg. 290814144), so // fetch the second value. if (ctype_digit((string) $checksum)) { return md5($checksum); } } return null; }
/** * ResourcePluginManager factory method. * * @param string $bin * The cache bin for the plugin manager. * @param RequestInterface $request * The request object. * * @return ResourcePluginManager * The created manager. */ public static function create($bin = 'cache', RequestInterface $request = NULL) { return new static(Module::getNamespaces(), _cache_get_object($bin), $request); }