Problem/Motivation

The Domain Access settings.inc file included by the site settings.php file fails if includes/cache.inc is already loaded. Therefore, the Domain Access modifications to settings.php must come before the modifications required by a caching module such as Memcache or APC.

Proposed resolution

The Domain Access documentation should mention this requirement.

Original report by ben soo

Hi, thot i should try starting up a new issue for this problem. The error i get is:

Domain access failed to load during phase: 2. Please check your settings.php file and site configuration.

What the domain module startup code says abt this phase:

/**
* Domain bootstrap phase 2: resolves host and does a lookup in the {domain}
* table. Also invokes hook "hook_domain_bootstrap_lookup".
*/

abt the only other info i can provide would be the query log the Devel module outputs for each page load. Would you want that?

Comments

ben soo’s picture

ok, i found something. Domain Access requires inclusion of a setup file as the last line in settings.php, after the memcache include files have been loaded. At the bottom of the Domain Access settings.inc setup file is this test:

/**
 * Small helper function to determine whether this file was included correctly in
 * the user's settings.php
 *
 * If it was included at the right time then cache.inc shouldn't be included
 * yet and the function 'cache_get' not be defined.
 *
 * When the function is called first (from within this file) the state is saved
 * in a static variable, every later call will return that boolean value.
 *
 * @return
 * TRUE if settings.inc was included correctly in settings.php, else FALSE
 */
function domain_settings_setup_ok() {
  $state = &drupal_static(__FUNCTION__, NULL);
  if ($state === NULL) {
    $state = !function_exists('cache_get');
  }
  return $state;
}

obviously the Memcache setup lines has caused cache_get() to be already defined by this point and so the function returns false to the Domain Access bootup code, and the bootstrap fails.

i've neutralized this test and just let Domain Access bootstrap, and run it a bit on a test site hosting 2 domains thru Domain Access, and it and Memcache so far co-exist fine.

pillarsdotnet’s picture

Title: D7 Domain Access module doesn't bootstrap with Memcache module running » The Domain Access settings.inc file must be included before any D7 caching module in the site settings.php file.
Project: Memcache API and Integration » Domain
Version: 7.x-0.0 » 7.x-3.x-dev
Component: Code » Documentation

In order for Domain Access and Memcache API and Integration to co-exist, the order of statements in the site settings.php file must be as follows:

/**
 * Domain Access
 */
require_once DRUPAL_ROOT . '/sites/all/modules/domain/settings.inc';

/**
 * Memcache API and Integration
 */
$conf['memcache_key_prefix'] = 'SITE_PREFIX_';
require_once DRUPAL_ROOT . '/includes/cache.inc';
require_once DRUPAL_ROOT . '/sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';

If the order is reversed, (Memcache before Domain Access), then Domain Access breaks but Memcache still works. Since Domain Access is the module with a specific requirement, Domain Access should document that requirement.

agentrickard’s picture

Status: Active » Closed (duplicate)

@ben soo.

This is a duplicate of a fixed issue that you cross-posted.

#1240472: Domain Access doesn't bootstrap when Memcache API installed

ben soo’s picture

Loading Domain Access before Memcache API didn't work for me-- generated a pile of database errors.

In any case, agentrickard has solved it.

@agentrickard

--yeps, sorry abt the duplication in the Memcache API issue queue; i did note it in the issue i started in the Domain Access issue queue, but had neglected to come back here to link to your solution.

EDIT: i dunno why this now shows up here since i posted it in Memcache.

ben soo’s picture

Issue summary: View changes

Corrected issue summary.