Issue #1608842 by chx, alexpott, sun, effulgentsia, beejeebus, tim.plunkett et al: Replace list of bootstrap modules, enabled modules, enabled themes, and default theme with config.
parent
16eac3bec5
commit
9fbe74405a
|
@ -890,28 +890,27 @@ function drupal_get_filename($type, $name, $filename = NULL) {
|
||||||
elseif (isset($files[$type][$name])) {
|
elseif (isset($files[$type][$name])) {
|
||||||
// nothing
|
// nothing
|
||||||
}
|
}
|
||||||
// Verify that we have an active database connection, before querying
|
|
||||||
// the database. This is required because this function is called both
|
|
||||||
// before we have a database connection (i.e. during installation) and
|
|
||||||
// when a database connection fails.
|
|
||||||
else {
|
else {
|
||||||
try {
|
// Verify that we have an keyvalue service before using it. This is required
|
||||||
if (function_exists('db_query')) {
|
// because this function is called during installation.
|
||||||
$file = db_query("SELECT filename FROM {system} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))->fetchField();
|
// @todo Inject database connection into KeyValueStore\DatabaseStorage.
|
||||||
if ($file && file_exists(DRUPAL_ROOT . '/' . $file)) {
|
if (drupal_container()->hasDefinition('keyvalue') && function_exists('db_query')) {
|
||||||
$files[$type][$name] = $file;
|
try {
|
||||||
|
$file_list = state()->get('system.' . $type . '.files');
|
||||||
|
if ($file_list && isset($file_list[$name]) && file_exists(DRUPAL_ROOT . '/' . $file_list[$name])) {
|
||||||
|
$files[$type][$name] = $file_list[$name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
// The keyvalue service raised an exception because the backend might
|
||||||
// The database table may not exist because Drupal is not yet installed,
|
// be down. We have a fallback for this case so we hide the error
|
||||||
// or the database might be down. We have a fallback for this case so we
|
// completely.
|
||||||
// hide the error completely.
|
}
|
||||||
}
|
}
|
||||||
// Fallback to searching the filesystem if the database could not find the
|
// Fallback to searching the filesystem if the database could not find the
|
||||||
// file or the file returned by the database is not found.
|
// file or the file returned by the database is not found.
|
||||||
if (!isset($files[$type][$name])) {
|
if (!isset($files[$type][$name])) {
|
||||||
// We have a consistent directory naming: modules, themes...
|
// We have consistent directory naming: modules, themes...
|
||||||
$dir = $type . 's';
|
$dir = $type . 's';
|
||||||
if ($type == 'theme_engine') {
|
if ($type == 'theme_engine') {
|
||||||
$dir = 'themes/engines';
|
$dir = 'themes/engines';
|
||||||
|
@ -2466,9 +2465,10 @@ function drupal_container(Container $new_container = NULL, $rebuild = FALSE) {
|
||||||
$container
|
$container
|
||||||
->register('config.storage.staging', 'Drupal\Core\Config\FileStorage')
|
->register('config.storage.staging', 'Drupal\Core\Config\FileStorage')
|
||||||
->addArgument(config_get_config_directory(CONFIG_STAGING_DIRECTORY));
|
->addArgument(config_get_config_directory(CONFIG_STAGING_DIRECTORY));
|
||||||
|
|
||||||
|
// Register the KeyValueStore factory.
|
||||||
$container
|
$container
|
||||||
->register('state.storage', 'Drupal\Core\KeyValueStore\DatabaseStorage')
|
->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueFactory');
|
||||||
->addArgument('state');
|
|
||||||
}
|
}
|
||||||
return $container;
|
return $container;
|
||||||
}
|
}
|
||||||
|
@ -2485,7 +2485,7 @@ function drupal_container(Container $new_container = NULL, $rebuild = FALSE) {
|
||||||
* @return Drupal\Core\KeyValueStore\KeyValueStoreInterface
|
* @return Drupal\Core\KeyValueStore\KeyValueStoreInterface
|
||||||
*/
|
*/
|
||||||
function state() {
|
function state() {
|
||||||
return drupal_container()->get('state.storage');
|
return drupal_container()->get('keyvalue')->get('state');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2504,16 +2504,22 @@ function typed_data() {
|
||||||
/**
|
/**
|
||||||
* Returns the test prefix if this is an internal request from SimpleTest.
|
* Returns the test prefix if this is an internal request from SimpleTest.
|
||||||
*
|
*
|
||||||
|
* @param string $new_prefix
|
||||||
|
* Internal use only. A new prefix to be stored. Passed in by tests that use
|
||||||
|
* the test runner from within a test.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
* Either the simpletest prefix (the string "simpletest" followed by any
|
* Either the simpletest prefix (the string "simpletest" followed by any
|
||||||
* number of digits) or FALSE if the user agent does not contain a valid
|
* number of digits) or FALSE if the user agent does not contain a valid
|
||||||
* HMAC and timestamp.
|
* HMAC and timestamp.
|
||||||
*/
|
*/
|
||||||
function drupal_valid_test_ua() {
|
function drupal_valid_test_ua($new_prefix = NULL) {
|
||||||
global $drupal_hash_salt;
|
global $drupal_hash_salt;
|
||||||
// No reason to reset this.
|
|
||||||
static $test_prefix;
|
static $test_prefix;
|
||||||
|
|
||||||
|
if (isset($new_prefix)) {
|
||||||
|
$test_prefix = $new_prefix;
|
||||||
|
}
|
||||||
if (isset($test_prefix)) {
|
if (isset($test_prefix)) {
|
||||||
return $test_prefix;
|
return $test_prefix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,9 +322,6 @@ function install_begin_request(&$install_state) {
|
||||||
$container->register('config.factory', 'Drupal\Core\Config\ConfigFactory')
|
$container->register('config.factory', 'Drupal\Core\Config\ConfigFactory')
|
||||||
->addArgument(new Reference('config.storage'))
|
->addArgument(new Reference('config.storage'))
|
||||||
->addArgument(new Reference('dispatcher'));
|
->addArgument(new Reference('dispatcher'));
|
||||||
$container
|
|
||||||
->register('state.storage', 'Drupal\Core\KeyValueStore\DatabaseStorage')
|
|
||||||
->addArgument('state');
|
|
||||||
drupal_container($container);
|
drupal_container($container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1661,15 +1658,12 @@ function install_import_translations_remaining(&$install_state) {
|
||||||
* A message informing the user that the installation is complete.
|
* A message informing the user that the installation is complete.
|
||||||
*/
|
*/
|
||||||
function install_finished(&$install_state) {
|
function install_finished(&$install_state) {
|
||||||
|
$profile = drupal_get_profile();
|
||||||
// Remember the profile which was used.
|
// Remember the profile which was used.
|
||||||
variable_set('install_profile', drupal_get_profile());
|
variable_set('install_profile', $profile);
|
||||||
|
|
||||||
// Installation profiles are always loaded last.
|
// Installation profiles are always loaded last.
|
||||||
db_update('system')
|
module_set_weight($profile, 1000);
|
||||||
->fields(array('weight' => 1000))
|
|
||||||
->condition('type', 'module')
|
|
||||||
->condition('name', drupal_get_profile())
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
// Flush all caches to ensure that any full bootstraps during the installer
|
// Flush all caches to ensure that any full bootstraps during the installer
|
||||||
// do not leave stale cached data, and that any content types or other items
|
// do not leave stale cached data, and that any content types or other items
|
||||||
|
|
|
@ -8,16 +8,6 @@
|
||||||
use Drupal\Core\Database\Database;
|
use Drupal\Core\Database\Database;
|
||||||
use Drupal\locale\Gettext;
|
use Drupal\locale\Gettext;
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates that a module has not been installed yet.
|
|
||||||
*/
|
|
||||||
const SCHEMA_UNINSTALLED = -1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates that a module has been installed.
|
|
||||||
*/
|
|
||||||
const SCHEMA_INSTALLED = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requirement severity -- Informational message only.
|
* Requirement severity -- Informational message only.
|
||||||
*/
|
*/
|
||||||
|
@ -420,28 +410,24 @@ function drupal_install_system() {
|
||||||
require_once DRUPAL_ROOT . '/' . $system_path . '/system.install';
|
require_once DRUPAL_ROOT . '/' . $system_path . '/system.install';
|
||||||
$system_versions = drupal_get_schema_versions('system');
|
$system_versions = drupal_get_schema_versions('system');
|
||||||
$system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED;
|
$system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED;
|
||||||
db_insert('system')
|
drupal_container()
|
||||||
->fields(array('filename', 'name', 'type', 'owner', 'status', 'schema_version', 'bootstrap'))
|
->get('keyvalue')
|
||||||
->values(array(
|
->get('system.schema')
|
||||||
'filename' => $system_path . '/system.module',
|
->set('system', $system_version);
|
||||||
'name' => 'system',
|
|
||||||
'type' => 'module',
|
|
||||||
'owner' => '',
|
|
||||||
'status' => 1,
|
|
||||||
'schema_version' => $system_version,
|
|
||||||
'bootstrap' => 0,
|
|
||||||
))
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
// Clear out module list and hook implementation statics before calling
|
// System module needs to be enabled and the system/module lists need to be
|
||||||
// system_rebuild_theme_data().
|
// reset first in order to allow config_install_default_config() to invoke
|
||||||
|
// config import callbacks.
|
||||||
|
// @todo Installation profiles may override the system.module config object.
|
||||||
|
config('system.module')
|
||||||
|
->set('enabled.system', 0)
|
||||||
|
->save();
|
||||||
|
|
||||||
|
// Clear out module list and hook implementation statics.
|
||||||
system_list_reset();
|
system_list_reset();
|
||||||
module_list_reset();
|
module_list_reset();
|
||||||
module_implements_reset();
|
module_implements_reset();
|
||||||
|
|
||||||
system_rebuild_module_data();
|
|
||||||
system_rebuild_theme_data();
|
|
||||||
|
|
||||||
config_install_default_config('module', 'system');
|
config_install_default_config('module', 'system');
|
||||||
|
|
||||||
module_invoke('system', 'install');
|
module_invoke('system', 'install');
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
use Drupal\Component\Graph\Graph;
|
use Drupal\Component\Graph\Graph;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all the modules that have been enabled in the system table.
|
* Loads all enabled modules.
|
||||||
*
|
*
|
||||||
* @param bool $bootstrap
|
* @param bool $bootstrap
|
||||||
* Whether to load only the reduced set of modules loaded in "bootstrap mode"
|
* Whether to load only the reduced set of modules loaded in "bootstrap mode"
|
||||||
|
@ -132,6 +132,11 @@ function module_list_reset() {
|
||||||
*
|
*
|
||||||
* @see module_list()
|
* @see module_list()
|
||||||
* @see list_themes()
|
* @see list_themes()
|
||||||
|
*
|
||||||
|
* @todo There are too many layers/levels of caching involved for system_list()
|
||||||
|
* data. Consider to add a config($name, $cache = TRUE) argument to allow
|
||||||
|
* callers like system_list() to force-disable a possible configuration
|
||||||
|
* storage controller cache or some other way to circumvent it/take it over.
|
||||||
*/
|
*/
|
||||||
function system_list($type) {
|
function system_list($type) {
|
||||||
$lists = &drupal_static(__FUNCTION__);
|
$lists = &drupal_static(__FUNCTION__);
|
||||||
|
@ -147,15 +152,15 @@ function system_list($type) {
|
||||||
$bootstrap_list = $cached->data;
|
$bootstrap_list = $cached->data;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$bootstrap_list = db_query("SELECT name, filename FROM {system} WHERE status = 1 AND bootstrap = 1 AND type = 'module' ORDER BY weight ASC, name ASC")->fetchAllAssoc('name');
|
$bootstrap_list = state()->get('system.module.bootstrap') ?: array();
|
||||||
cache('bootstrap')->set('bootstrap_modules', $bootstrap_list);
|
cache('bootstrap')->set('bootstrap_modules', $bootstrap_list);
|
||||||
}
|
}
|
||||||
// To avoid a separate database lookup for the filepath, prime the
|
// To avoid a separate database lookup for the filepath, prime the
|
||||||
// drupal_get_filename() static cache for bootstrap modules only.
|
// drupal_get_filename() static cache for bootstrap modules only.
|
||||||
// The rest is stored separately to keep the bootstrap module cache small.
|
// The rest is stored separately to keep the bootstrap module cache small.
|
||||||
foreach ($bootstrap_list as $module) {
|
foreach ($bootstrap_list as $name => $filename) {
|
||||||
drupal_classloader_register($module->name, dirname($module->filename));
|
drupal_classloader_register($name, dirname($filename));
|
||||||
drupal_get_filename('module', $module->name, $module->filename);
|
drupal_get_filename('module', $name, $filename);
|
||||||
}
|
}
|
||||||
// We only return the module names here since module_list() doesn't need
|
// We only return the module names here since module_list() doesn't need
|
||||||
// the filename itself.
|
// the filename itself.
|
||||||
|
@ -177,22 +182,48 @@ function system_list($type) {
|
||||||
// Drupal installations, which might have modules installed in different
|
// Drupal installations, which might have modules installed in different
|
||||||
// locations in the file system. The ordering here must also be
|
// locations in the file system. The ordering here must also be
|
||||||
// consistent with the one used in module_implements().
|
// consistent with the one used in module_implements().
|
||||||
$result = db_query("SELECT * FROM {system} WHERE type = 'theme' OR (type = 'module' AND status = 1) ORDER BY weight ASC, name ASC");
|
$enabled_modules = config('system.module')->get('enabled');
|
||||||
foreach ($result as $record) {
|
$module_files = state()->get('system.module.files');
|
||||||
|
foreach ($enabled_modules as $name => $weight) {
|
||||||
// Build a list of all enabled modules.
|
// Build a list of all enabled modules.
|
||||||
if ($record->type == 'module') {
|
$lists['module_enabled'][$name] = $name;
|
||||||
$lists['module_enabled'][$record->name] = $record->name;
|
|
||||||
}
|
|
||||||
// Build a list of themes.
|
|
||||||
if ($record->type == 'theme') {
|
|
||||||
$record->info = unserialize($record->info);
|
|
||||||
$lists['theme'][$record->name] = $record;
|
|
||||||
}
|
|
||||||
// Build a list of filenames so drupal_get_filename can use it.
|
// Build a list of filenames so drupal_get_filename can use it.
|
||||||
if ($record->status) {
|
$lists['filepaths'][] = array(
|
||||||
$lists['filepaths'][] = array('type' => $record->type, 'name' => $record->name, 'filepath' => $record->filename);
|
'type' => 'module',
|
||||||
|
'name' => $name,
|
||||||
|
'filepath' => $module_files[$name],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build a list of themes.
|
||||||
|
$enabled_themes = config('system.theme')->get('enabled');
|
||||||
|
// @todo Themes include all themes, including disabled/uninstalled. This
|
||||||
|
// system.theme.data state will go away entirely as soon as themes have
|
||||||
|
// a proper installation status.
|
||||||
|
// @see http://drupal.org/node/1067408
|
||||||
|
$theme_data = state()->get('system.theme.data');
|
||||||
|
if (empty($theme_data)) {
|
||||||
|
// @todo: system_list() may be called from _drupal_bootstrap_code() and
|
||||||
|
// module_load_all(), in which case system.module is not loaded yet.
|
||||||
|
// Prevent a filesystem scan in drupal_load() and include it directly.
|
||||||
|
// @see http://drupal.org/node/1067408
|
||||||
|
require_once DRUPAL_ROOT . '/core/modules/system/system.module';
|
||||||
|
$theme_data = system_rebuild_theme_data();
|
||||||
|
}
|
||||||
|
foreach ($theme_data as $name => $theme) {
|
||||||
|
$theme->status = (int) isset($enabled_themes[$name]);
|
||||||
|
$lists['theme'][$name] = $theme;
|
||||||
|
// Build a list of filenames so drupal_get_filename can use it.
|
||||||
|
if (isset($enabled_themes[$name])) {
|
||||||
|
$lists['filepaths'][] = array(
|
||||||
|
'type' => 'theme',
|
||||||
|
'name' => $name,
|
||||||
|
'filepath' => $theme->filename,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// @todo Move into list_themes(). Read info for a particular requested
|
||||||
|
// theme from state instead.
|
||||||
foreach ($lists['theme'] as $key => $theme) {
|
foreach ($lists['theme'] as $key => $theme) {
|
||||||
if (!empty($theme->info['base theme'])) {
|
if (!empty($theme->info['base theme'])) {
|
||||||
// Make a list of the theme's base themes.
|
// Make a list of the theme's base themes.
|
||||||
|
@ -240,6 +271,14 @@ function system_list_reset() {
|
||||||
drupal_static_reset('list_themes');
|
drupal_static_reset('list_themes');
|
||||||
cache('bootstrap')->deleteMultiple(array('bootstrap_modules', 'system_list'));
|
cache('bootstrap')->deleteMultiple(array('bootstrap_modules', 'system_list'));
|
||||||
cache()->delete('system_info');
|
cache()->delete('system_info');
|
||||||
|
// Remove last known theme data state.
|
||||||
|
// This causes system_list() to call system_rebuild_theme_data() on its next
|
||||||
|
// invocation. When enabling a module that implements hook_system_info_alter()
|
||||||
|
// to inject a new (testing) theme or manipulate an existing theme, then that
|
||||||
|
// will cause system_list_reset() to be called, but theme data is not
|
||||||
|
// necessarily rebuilt afterwards.
|
||||||
|
// @todo Obsolete with proper installation status for themes.
|
||||||
|
state()->delete('system.theme.data');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -348,7 +387,7 @@ function module_load_include($type, $module, $name = NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads an include file for each module enabled in the {system} table.
|
* Loads an include file for each enabled module.
|
||||||
*/
|
*/
|
||||||
function module_load_all_includes($type, $name = NULL) {
|
function module_load_all_includes($type, $name = NULL) {
|
||||||
$modules = module_list();
|
$modules = module_list();
|
||||||
|
@ -436,26 +475,28 @@ function module_enable($module_list, $enable_dependencies = TRUE) {
|
||||||
|
|
||||||
$modules_installed = array();
|
$modules_installed = array();
|
||||||
$modules_enabled = array();
|
$modules_enabled = array();
|
||||||
|
$schema_store = drupal_container()->get('keyvalue')->get('system.schema');
|
||||||
|
$module_config = config('system.module');
|
||||||
|
$disabled_config = config('system.module.disabled');
|
||||||
foreach ($module_list as $module) {
|
foreach ($module_list as $module) {
|
||||||
// Only process modules that are not already enabled.
|
// Only process modules that are not already enabled.
|
||||||
$existing = db_query("SELECT status FROM {system} WHERE type = :type AND name = :name", array(
|
$enabled = $module_config->get("enabled.$module") !== NULL;
|
||||||
':type' => 'module',
|
if (!$enabled) {
|
||||||
':name' => $module))
|
$weight = $disabled_config->get($module);
|
||||||
->fetchObject();
|
if ($weight === NULL) {
|
||||||
if ($existing->status == 0) {
|
$weight = 0;
|
||||||
|
}
|
||||||
|
$module_config
|
||||||
|
->set("enabled.$module", $weight)
|
||||||
|
->set('enabled', module_config_sort($module_config->get('enabled')))
|
||||||
|
->save();
|
||||||
|
$disabled_config
|
||||||
|
->clear($module)
|
||||||
|
->save();
|
||||||
// Load the module's code.
|
// Load the module's code.
|
||||||
drupal_load('module', $module);
|
drupal_load('module', $module);
|
||||||
module_load_install($module);
|
module_load_install($module);
|
||||||
|
|
||||||
// Update the database and module list to reflect the new module. This
|
|
||||||
// needs to be done first so that the module's hook implementations,
|
|
||||||
// hook_schema() in particular, can be called while it is being
|
|
||||||
// installed.
|
|
||||||
db_update('system')
|
|
||||||
->fields(array('status' => 1))
|
|
||||||
->condition('type', 'module')
|
|
||||||
->condition('name', $module)
|
|
||||||
->execute();
|
|
||||||
// Refresh the module list to include it.
|
// Refresh the module list to include it.
|
||||||
system_list_reset();
|
system_list_reset();
|
||||||
module_implements_reset();
|
module_implements_reset();
|
||||||
|
@ -565,15 +606,18 @@ function module_disable($module_list, $disable_dependents = TRUE) {
|
||||||
|
|
||||||
$invoke_modules = array();
|
$invoke_modules = array();
|
||||||
|
|
||||||
|
$module_config = config('system.module');
|
||||||
|
$disabled_config = config('system.module.disabled');
|
||||||
foreach ($module_list as $module) {
|
foreach ($module_list as $module) {
|
||||||
if (module_exists($module)) {
|
if (module_exists($module)) {
|
||||||
module_load_install($module);
|
module_load_install($module);
|
||||||
module_invoke($module, 'disable');
|
module_invoke($module, 'disable');
|
||||||
db_update('system')
|
$disabled_config
|
||||||
->fields(array('status' => 0))
|
->set($module, $module_config->get($module))
|
||||||
->condition('type', 'module')
|
->save();
|
||||||
->condition('name', $module)
|
$module_config
|
||||||
->execute();
|
->clear("enabled.$module")
|
||||||
|
->save();
|
||||||
$invoke_modules[] = $module;
|
$invoke_modules[] = $module;
|
||||||
watchdog('system', '%module module disabled.', array('%module' => $module), WATCHDOG_INFO);
|
watchdog('system', '%module module disabled.', array('%module' => $module), WATCHDOG_INFO);
|
||||||
}
|
}
|
||||||
|
@ -642,6 +686,8 @@ function module_uninstall($module_list = array(), $uninstall_dependents = TRUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
$storage = drupal_container()->get('config.storage');
|
$storage = drupal_container()->get('config.storage');
|
||||||
|
$schema_store = drupal_container()->get('keyvalue')->get('system.schema');
|
||||||
|
$disabled_config = config('system.module.disabled');
|
||||||
foreach ($module_list as $module) {
|
foreach ($module_list as $module) {
|
||||||
// Uninstall the module.
|
// Uninstall the module.
|
||||||
module_load_install($module);
|
module_load_install($module);
|
||||||
|
@ -655,8 +701,11 @@ function module_uninstall($module_list = array(), $uninstall_dependents = TRUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
watchdog('system', '%module module uninstalled.', array('%module' => $module), WATCHDOG_INFO);
|
watchdog('system', '%module module uninstalled.', array('%module' => $module), WATCHDOG_INFO);
|
||||||
drupal_set_installed_schema_version($module, SCHEMA_UNINSTALLED);
|
$schema_store->delete($module);
|
||||||
|
$disabled_config->clear($module);
|
||||||
}
|
}
|
||||||
|
$disabled_config->save();
|
||||||
|
drupal_get_installed_schema_version(NULL, TRUE);
|
||||||
|
|
||||||
if (!empty($module_list)) {
|
if (!empty($module_list)) {
|
||||||
// Call hook_module_uninstall to let other modules act
|
// Call hook_module_uninstall to let other modules act
|
||||||
|
@ -1124,3 +1173,65 @@ function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
|
||||||
$function($data, $context1, $context2);
|
$function($data, $context1, $context2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets weight of a particular module.
|
||||||
|
*
|
||||||
|
* The weight of uninstalled modules cannot be changed.
|
||||||
|
*
|
||||||
|
* @param string $module
|
||||||
|
* The name of the module (without the .module extension).
|
||||||
|
* @param int $weight
|
||||||
|
* An integer representing the weight of the module.
|
||||||
|
*/
|
||||||
|
function module_set_weight($module, $weight) {
|
||||||
|
// Update the module weight in the config file that contains it.
|
||||||
|
$module_config = config('system.module');
|
||||||
|
if ($module_config->get("enabled.$module") !== NULL) {
|
||||||
|
$module_config
|
||||||
|
->set("enabled.$module", $weight)
|
||||||
|
->set('enabled', module_config_sort($module_config->get('enabled')))
|
||||||
|
->save();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$disabled_config = config('system.module.disabled');
|
||||||
|
if ($disabled_config->get($module) !== NULL) {
|
||||||
|
$disabled_config
|
||||||
|
->set($module, $weight)
|
||||||
|
->save();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sorts the configured list of enabled modules.
|
||||||
|
*
|
||||||
|
* The list of enabled modules is expected to be ordered by weight and name.
|
||||||
|
* The list is always sorted on write to avoid the overhead on read.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* An array of module configuration data.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* An array of module configuration data sorted by weight and name.
|
||||||
|
*/
|
||||||
|
function module_config_sort($data) {
|
||||||
|
// PHP array sorting functions such as uasort() do not work with both keys and
|
||||||
|
// values at the same time, so we achieve weight and name sorting by computing
|
||||||
|
// strings with both information concatenated (weight first, name second) and
|
||||||
|
// use that as a regular string sort reference list via array_multisort(),
|
||||||
|
// compound of "[sign-as-integer][padded-integer-weight][name]"; e.g., given
|
||||||
|
// two modules and weights (spaces added for clarity):
|
||||||
|
// - Block with weight -5: 0 0000000000000000005 block
|
||||||
|
// - Node with weight 0: 1 0000000000000000000 node
|
||||||
|
$sort = array();
|
||||||
|
foreach ($data as $name => $weight) {
|
||||||
|
// Prefix negative weights with 0, positive weights with 1.
|
||||||
|
// +/- signs cannot be used, since + (ASCII 43) is before - (ASCII 45).
|
||||||
|
$prefix = (int) ($weight >= 0);
|
||||||
|
// The maximum weight is PHP_INT_MAX, so pad all weights to 19 digits.
|
||||||
|
$sort[] = $prefix . sprintf('%019d', abs($weight)) . $name;
|
||||||
|
}
|
||||||
|
array_multisort($sort, SORT_STRING, $data);
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
|
@ -14,6 +14,16 @@ use Drupal\Core\Utility\SchemaCache;
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates that a module has not been installed yet.
|
||||||
|
*/
|
||||||
|
const SCHEMA_UNINSTALLED = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates that a module has been installed.
|
||||||
|
*/
|
||||||
|
const SCHEMA_INSTALLED = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the schema definition of a table, or the whole database schema.
|
* Gets the schema definition of a table, or the whole database schema.
|
||||||
*
|
*
|
||||||
|
@ -156,7 +166,7 @@ function drupal_get_schema_versions($module) {
|
||||||
* @param string $module
|
* @param string $module
|
||||||
* A module name.
|
* A module name.
|
||||||
* @param bool $reset
|
* @param bool $reset
|
||||||
* Set to TRUE after modifying the system table.
|
* Set to TRUE after installing or uninstalling an extension.
|
||||||
* @param bool $array
|
* @param bool $array
|
||||||
* Set to TRUE if you want to get information about all modules in the
|
* Set to TRUE if you want to get information about all modules in the
|
||||||
* system.
|
* system.
|
||||||
|
@ -173,10 +183,8 @@ function drupal_get_installed_schema_version($module, $reset = FALSE, $array = F
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$versions) {
|
if (!$versions) {
|
||||||
$versions = array();
|
if (!$versions = drupal_container()->get('keyvalue')->get('system.schema')->getAll()) {
|
||||||
$result = db_query("SELECT name, schema_version FROM {system} WHERE type = :type", array(':type' => 'module'));
|
$versions = array();
|
||||||
foreach ($result as $row) {
|
|
||||||
$versions[$row->name] = $row->schema_version;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,11 +205,7 @@ function drupal_get_installed_schema_version($module, $reset = FALSE, $array = F
|
||||||
* The new schema version.
|
* The new schema version.
|
||||||
*/
|
*/
|
||||||
function drupal_set_installed_schema_version($module, $version) {
|
function drupal_set_installed_schema_version($module, $version) {
|
||||||
db_update('system')
|
drupal_container()->get('keyvalue')->get('system.schema')->set($module, $version);
|
||||||
->fields(array('schema_version' => $version))
|
|
||||||
->condition('name', $module)
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
// Reset the static cache of module schema versions.
|
// Reset the static cache of module schema versions.
|
||||||
drupal_get_installed_schema_version(NULL, TRUE);
|
drupal_get_installed_schema_version(NULL, TRUE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1412,17 +1412,17 @@ function theme_render_template($template_file, $variables) {
|
||||||
*/
|
*/
|
||||||
function theme_enable($theme_list) {
|
function theme_enable($theme_list) {
|
||||||
drupal_clear_css_cache();
|
drupal_clear_css_cache();
|
||||||
|
$theme_config = config('system.theme');
|
||||||
|
$disabled_themes = config('system.theme.disabled');
|
||||||
foreach ($theme_list as $key) {
|
foreach ($theme_list as $key) {
|
||||||
db_update('system')
|
// The value is not used; the weight is ignored for themes currently.
|
||||||
->fields(array('status' => 1))
|
$theme_config->set("enabled.$key", 0);
|
||||||
->condition('type', 'theme')
|
$disabled_themes->clear($key);
|
||||||
->condition('name', $key)
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
// Install default configuration of the theme.
|
// Install default configuration of the theme.
|
||||||
config_install_default_config('theme', $key);
|
config_install_default_config('theme', $key);
|
||||||
}
|
}
|
||||||
|
$theme_config->save();
|
||||||
|
$disabled_themes->save();
|
||||||
|
|
||||||
list_themes(TRUE);
|
list_themes(TRUE);
|
||||||
menu_router_rebuild();
|
menu_router_rebuild();
|
||||||
|
@ -1449,13 +1449,15 @@ function theme_disable($theme_list) {
|
||||||
|
|
||||||
drupal_clear_css_cache();
|
drupal_clear_css_cache();
|
||||||
|
|
||||||
|
$theme_config = config('system.theme');
|
||||||
|
$disabled_themes = config('system.theme.disabled');
|
||||||
foreach ($theme_list as $key) {
|
foreach ($theme_list as $key) {
|
||||||
db_update('system')
|
// The value is not used; the weight is ignored for themes currently.
|
||||||
->fields(array('status' => 0))
|
$theme_config->clear("enabled.$key");
|
||||||
->condition('type', 'theme')
|
$disabled_themes->set($key, 0);
|
||||||
->condition('name', $key)
|
|
||||||
->execute();
|
|
||||||
}
|
}
|
||||||
|
$theme_config->save();
|
||||||
|
$disabled_themes->save();
|
||||||
|
|
||||||
list_themes(TRUE);
|
list_themes(TRUE);
|
||||||
menu_router_rebuild();
|
menu_router_rebuild();
|
||||||
|
|
|
@ -19,26 +19,29 @@ use Drupal\Component\Uuid\Uuid;
|
||||||
* Upgrades from Drupal 7 to Drupal 8 require that Drupal 7 be running
|
* Upgrades from Drupal 7 to Drupal 8 require that Drupal 7 be running
|
||||||
* the most recent version, or the upgrade could fail. We can't easily
|
* the most recent version, or the upgrade could fail. We can't easily
|
||||||
* check the Drupal 7 version once the update process has begun, so instead
|
* check the Drupal 7 version once the update process has begun, so instead
|
||||||
* we check the schema version of system.module in the system table.
|
* we check the schema version of system.module.
|
||||||
*/
|
*/
|
||||||
const REQUIRED_D7_SCHEMA_VERSION = '7069';
|
const REQUIRED_D7_SCHEMA_VERSION = '7069';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable any items in the {system} table that are not core compatible.
|
* Disables any extensions that are incompatible with the current core version.
|
||||||
*/
|
*/
|
||||||
function update_fix_compatibility() {
|
function update_fix_compatibility() {
|
||||||
$incompatible = array();
|
foreach (array('module', 'theme') as $type) {
|
||||||
$result = db_query("SELECT name, type, status FROM {system} WHERE status = 1 AND type IN ('module','theme')");
|
$config = config("system.$type");
|
||||||
foreach ($result as $row) {
|
$save = FALSE;
|
||||||
if (update_check_incompatibility($row->name, $row->type)) {
|
foreach ($config->get('enabled') as $name => $weight) {
|
||||||
$incompatible[] = $row->name;
|
if (update_check_incompatibility($name, $type)) {
|
||||||
|
$config->clear("enabled.$name");
|
||||||
|
$save = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($save) {
|
||||||
|
if ($type == 'module') {
|
||||||
|
$config->set('enabled', module_config_sort($config->get('enabled')));
|
||||||
|
}
|
||||||
|
$config->save();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!empty($incompatible)) {
|
|
||||||
db_update('system')
|
|
||||||
->fields(array('status' => 0))
|
|
||||||
->condition('name', $incompatible, 'IN')
|
|
||||||
->execute();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +120,12 @@ function update_prepare_d8_bootstrap() {
|
||||||
// running an up-to-date version of Drupal 7 before proceeding. Note this has
|
// running an up-to-date version of Drupal 7 before proceeding. Note this has
|
||||||
// to happen AFTER the database bootstraps because of
|
// to happen AFTER the database bootstraps because of
|
||||||
// drupal_get_installed_schema_version().
|
// drupal_get_installed_schema_version().
|
||||||
$system_schema = drupal_get_installed_schema_version('system');
|
try {
|
||||||
|
$system_schema = drupal_get_installed_schema_version('system');
|
||||||
|
}
|
||||||
|
catch (\Exception $e) {
|
||||||
|
$system_schema = db_query('SELECT schema_version FROM {system} WHERE name = :system', array(':system' => 'system'))->fetchField();
|
||||||
|
}
|
||||||
if ($system_schema < 8000) {
|
if ($system_schema < 8000) {
|
||||||
$has_required_schema = $system_schema >= REQUIRED_D7_SCHEMA_VERSION;
|
$has_required_schema = $system_schema >= REQUIRED_D7_SCHEMA_VERSION;
|
||||||
$requirements = array(
|
$requirements = array(
|
||||||
|
@ -130,6 +138,10 @@ function update_prepare_d8_bootstrap() {
|
||||||
);
|
);
|
||||||
update_extra_requirements($requirements);
|
update_extra_requirements($requirements);
|
||||||
|
|
||||||
|
// @todo update.php stages seem to be completely screwed up; the initial
|
||||||
|
// requirements check is not supposed to change the system. All of the
|
||||||
|
// following code seems to have been mistakenly/unknowingly added here and
|
||||||
|
// does not belong into update_prepare_d8_bootstrap().
|
||||||
if ($has_required_schema) {
|
if ($has_required_schema) {
|
||||||
if (!db_table_exists('key_value')) {
|
if (!db_table_exists('key_value')) {
|
||||||
$specs = array(
|
$specs = array(
|
||||||
|
@ -164,18 +176,91 @@ function update_prepare_d8_bootstrap() {
|
||||||
// Bootstrap variables so we can update theme while preparing the update
|
// Bootstrap variables so we can update theme while preparing the update
|
||||||
// process.
|
// process.
|
||||||
drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
|
drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
|
||||||
// Update the dynamic include paths that might be used before running the
|
|
||||||
// proper update functions.
|
|
||||||
update_prepare_stored_includes();
|
|
||||||
// Update the environment for the language bootstrap if needed.
|
|
||||||
update_prepare_d8_language();
|
|
||||||
|
|
||||||
|
// Update the 'language_default' system variable, if configured.
|
||||||
|
// Required to run before drupal_install_config_directories(), since that
|
||||||
|
// triggers a call into system_stream_wrappers(), which calls t(), which
|
||||||
|
// calls into language_default().
|
||||||
|
$language_default = variable_get('language_default');
|
||||||
|
if (!empty($language_default) && (isset($language_default->langcode) || isset($language_default->language))) {
|
||||||
|
if (!isset($language_default->langcode)) {
|
||||||
|
$language_default->langcode = $language_default->language;
|
||||||
|
}
|
||||||
|
unset($language_default->language);
|
||||||
|
// In D8, the 'language_default' is not anymore an object, but an array,
|
||||||
|
// so make sure that the new value that is saved into this variable is an
|
||||||
|
// array.
|
||||||
|
variable_set('language_default', (array) $language_default);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @todo Race-condition: drupal_install_config_directories() calls into
|
||||||
|
// install_ensure_config_directory(), which calls into
|
||||||
|
// file_prepare_directory(), whichs calls into file_get_stream_wrappers(),
|
||||||
|
// which attempts to invoke hooks with a non-existing module/hook system.
|
||||||
|
include_once DRUPAL_ROOT . '/core/includes/module.inc';
|
||||||
|
$module_list['system']['filename'] = 'core/modules/system/system.module';
|
||||||
|
module_list(NULL, $module_list);
|
||||||
|
require_once DRUPAL_ROOT . '/' . $module_list['system']['filename'];
|
||||||
// Ensure the configuration directories exist and are writable, or create
|
// Ensure the configuration directories exist and are writable, or create
|
||||||
// them. If the directories have not been specified in settings.php and
|
// them. If the directories have not been specified in settings.php and
|
||||||
// created manually already, and either directory cannot be created by the
|
// created manually already, and either directory cannot be created by the
|
||||||
// web server, an exception will be thrown, halting the update.
|
// web server, an exception will be thrown, halting the update.
|
||||||
drupal_install_config_directories();
|
drupal_install_config_directories();
|
||||||
|
|
||||||
|
$module_config = config('system.module');
|
||||||
|
$disabled_modules = config('system.module.disabled');
|
||||||
|
$theme_config = config('system.theme');
|
||||||
|
$disabled_themes = config('system.theme.disabled');
|
||||||
|
$schema_store = drupal_container()->get('keyvalue')->get('system.schema');
|
||||||
|
|
||||||
|
// Load system.module, because update_prepare_d8_bootstrap() is called in
|
||||||
|
// the initial minimal update.php bootstrap that performs the core
|
||||||
|
// requirements check.
|
||||||
|
require_once DRUPAL_ROOT . '/core/modules/system/system.module';
|
||||||
|
|
||||||
|
// Retrieve all installed extensions from the {system} table.
|
||||||
|
// Uninstalled extensions are ignored and not converted.
|
||||||
|
$result = db_query('SELECT name, status, weight, schema_version, type FROM {system} WHERE type = :theme OR (type = :module AND schema_version <> :schema_uninstalled)', array(
|
||||||
|
':theme' => 'theme',
|
||||||
|
':module' => 'module',
|
||||||
|
':schema_uninstalled' => SCHEMA_UNINSTALLED,
|
||||||
|
));
|
||||||
|
$module_data = _system_rebuild_module_data();
|
||||||
|
|
||||||
|
// Migrate each extension into configuration, varying by the extension's
|
||||||
|
// status, and record its schema version.
|
||||||
|
foreach ($result as $record) {
|
||||||
|
if ($record->type == 'module') {
|
||||||
|
if ($record->status && isset($module_data[$record->name])) {
|
||||||
|
$module_config->set('enabled.' . $record->name, $record->weight);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$disabled_modules->set($record->name, $record->weight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($record->type == 'theme') {
|
||||||
|
if ($record->status) {
|
||||||
|
$theme_config->set('enabled.' . $record->name, 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$disabled_themes->set($record->name, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$schema_store->set($record->name, $record->schema_version);
|
||||||
|
}
|
||||||
|
$module_config->set('enabled', module_config_sort($module_config->get('enabled')))->save();
|
||||||
|
$disabled_modules->save();
|
||||||
|
$theme_config->save();
|
||||||
|
$disabled_themes->save();
|
||||||
|
|
||||||
|
// Update the dynamic include paths that might be used before running the
|
||||||
|
// proper update functions.
|
||||||
|
update_prepare_stored_includes();
|
||||||
|
// Update the environment for the language bootstrap if needed.
|
||||||
|
update_prepare_d8_language();
|
||||||
|
// Prime the classloader.
|
||||||
|
system_list('module_enabled');
|
||||||
|
|
||||||
// Change language column to langcode in url_alias.
|
// Change language column to langcode in url_alias.
|
||||||
if (db_table_exists('url_alias') && db_field_exists('url_alias', 'language')) {
|
if (db_table_exists('url_alias') && db_field_exists('url_alias', 'language')) {
|
||||||
db_drop_index('url_alias', 'alias_language_pid');
|
db_drop_index('url_alias', 'alias_language_pid');
|
||||||
|
@ -260,7 +345,6 @@ function update_prepare_d8_language() {
|
||||||
// version of this function to ensure schema conflicts don't happen due to
|
// version of this function to ensure schema conflicts don't happen due to
|
||||||
// our updated data.
|
// our updated data.
|
||||||
$modules = array('language');
|
$modules = array('language');
|
||||||
update_module_add_to_system($modules);
|
|
||||||
update_module_enable($modules);
|
update_module_enable($modules);
|
||||||
|
|
||||||
// Rename language column to langcode and set it again as the primary key.
|
// Rename language column to langcode and set it again as the primary key.
|
||||||
|
@ -276,19 +360,6 @@ function update_prepare_d8_language() {
|
||||||
db_change_field('language', 'language', 'langcode', $langcode_spec, array('primary key' => array('langcode')));
|
db_change_field('language', 'language', 'langcode', $langcode_spec, array('primary key' => array('langcode')));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the 'language_default' system variable, if configured.
|
|
||||||
$language_default = variable_get('language_default');
|
|
||||||
if (!empty($language_default) && (isset($language_default->langcode) || isset($language_default->language))) {
|
|
||||||
if (!isset($language_default->langcode)) {
|
|
||||||
$language_default->langcode = $language_default->language;
|
|
||||||
}
|
|
||||||
unset($language_default->language);
|
|
||||||
// In D8, the 'language_default' is not anymore an object, but an array,
|
|
||||||
// so make sure that the new value that is saved into this variable is an
|
|
||||||
// array.
|
|
||||||
variable_set('language_default', (array) $language_default);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adds the locked column and saves the special languages.
|
// Adds the locked column and saves the special languages.
|
||||||
if (!db_field_exists('language', 'locked')) {
|
if (!db_field_exists('language', 'locked')) {
|
||||||
$locked_spec = array(
|
$locked_spec = array(
|
||||||
|
@ -331,41 +402,6 @@ function update_prepare_d8_language() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds modules to the system table in a Drupal core update.
|
|
||||||
*
|
|
||||||
* @param $modules
|
|
||||||
* Array of module names.
|
|
||||||
*/
|
|
||||||
function update_module_add_to_system($modules = array()) {
|
|
||||||
// Insert module data, so we can enable the module. Calling a full module
|
|
||||||
// list rebuild so early is costly and complex, so we just have a stop-gap.
|
|
||||||
$info_defaults = array(
|
|
||||||
'dependencies' => array(),
|
|
||||||
'description' => '',
|
|
||||||
'package' => 'Other',
|
|
||||||
'version' => NULL,
|
|
||||||
'php' => DRUPAL_MINIMUM_PHP,
|
|
||||||
'files' => array(),
|
|
||||||
'bootstrap' => 0,
|
|
||||||
);
|
|
||||||
foreach ($modules as $module) {
|
|
||||||
$module_info = drupal_parse_info_file('core/modules/' . $module . '/' . $module . '.info');
|
|
||||||
db_insert('system')
|
|
||||||
->fields(array(
|
|
||||||
'filename' => 'core/modules/' . $module . '/' . $module . '.module',
|
|
||||||
'name' => $module,
|
|
||||||
'type' => 'module',
|
|
||||||
'status' => 0,
|
|
||||||
'bootstrap' => 0,
|
|
||||||
'schema_version' => -1,
|
|
||||||
'weight' => 0,
|
|
||||||
'info' => serialize($module_info + $info_defaults),
|
|
||||||
))
|
|
||||||
->execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform Drupal 7.x to 8.x updates that are required for update.php
|
* Perform Drupal 7.x to 8.x updates that are required for update.php
|
||||||
* to function properly.
|
* to function properly.
|
||||||
|
@ -388,6 +424,7 @@ function update_fix_d8_requirements() {
|
||||||
* Helper function to install a new module in Drupal 8 via hook_update_N().
|
* Helper function to install a new module in Drupal 8 via hook_update_N().
|
||||||
*/
|
*/
|
||||||
function update_module_enable(array $modules) {
|
function update_module_enable(array $modules) {
|
||||||
|
$schema_store = drupal_container()->get('keyvalue')->get('system.schema');
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
// Check for initial schema and install it. The schema version of a newly
|
// Check for initial schema and install it. The schema version of a newly
|
||||||
// installed module is always 0. Using 8000 here would be inconsistent
|
// installed module is always 0. Using 8000 here would be inconsistent
|
||||||
|
@ -400,13 +437,19 @@ function update_module_enable(array $modules) {
|
||||||
db_create_table($table, $spec);
|
db_create_table($table, $spec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Enable the module with a weight of 0.
|
||||||
|
$module_config = config('system.module');
|
||||||
|
$module_config
|
||||||
|
->set("enabled.$module", 0)
|
||||||
|
->set('enabled', module_config_sort($module_config->get('enabled')))
|
||||||
|
->save();
|
||||||
|
// Ensure the module is not contained in disabled modules.
|
||||||
|
config('system.module.disabled')
|
||||||
|
->clear($module)
|
||||||
|
->save();
|
||||||
// Change the schema version from SCHEMA_UNINSTALLED to 0, so any module
|
// Change the schema version from SCHEMA_UNINSTALLED to 0, so any module
|
||||||
// updates since the module's inception are executed in a core upgrade.
|
// updates since the module's inception are executed in a core upgrade.
|
||||||
db_update('system')
|
$schema_store->set($module, 0);
|
||||||
->condition('type', 'module')
|
|
||||||
->condition('name', $module)
|
|
||||||
->fields(array('schema_version' => 0, 'status' => 1))
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
// system_list_reset() is in module.inc but that would only be available
|
// system_list_reset() is in module.inc but that would only be available
|
||||||
// once the variable bootstrap is done.
|
// once the variable bootstrap is done.
|
||||||
|
@ -941,8 +984,7 @@ function update_retrieve_dependencies() {
|
||||||
$return = array();
|
$return = array();
|
||||||
// Get a list of installed modules, arranged so that we invoke their hooks in
|
// Get a list of installed modules, arranged so that we invoke their hooks in
|
||||||
// the same order that module_invoke_all() does.
|
// the same order that module_invoke_all() does.
|
||||||
$modules = db_query("SELECT name FROM {system} WHERE type = 'module' AND schema_version <> :schema ORDER BY weight ASC, name ASC", array(':schema' => SCHEMA_UNINSTALLED))->fetchCol();
|
foreach (config('system.module')->get('enabled') as $module => $weight) {
|
||||||
foreach ($modules as $module) {
|
|
||||||
$function = $module . '_update_dependencies';
|
$function = $module . '_update_dependencies';
|
||||||
if (function_exists($function)) {
|
if (function_exists($function)) {
|
||||||
$result = $function();
|
$result = $function();
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Contains Drupal\Core\KeyValueStore\KeyValueFactory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Drupal\Core\KeyValueStore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the key/value store factory.
|
||||||
|
*/
|
||||||
|
class KeyValueFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiated stores, keyed by collection name.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $stores = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new key/value store for a given collection name.
|
||||||
|
*
|
||||||
|
* @param string $collection
|
||||||
|
* The name of the collection holding key and value pairs.
|
||||||
|
*
|
||||||
|
* @return Drupal\Core\KeyValueStore\DatabaseStorage
|
||||||
|
* A key/value store implementation for the given $collection.
|
||||||
|
*/
|
||||||
|
public function get($collection) {
|
||||||
|
if (!isset($this->stores[$collection])) {
|
||||||
|
$this->stores[$collection] = new DatabaseStorage($collection);
|
||||||
|
}
|
||||||
|
return $this->stores[$collection];
|
||||||
|
}
|
||||||
|
}
|
|
@ -72,7 +72,7 @@ class Theme extends Updater implements UpdaterInterface {
|
||||||
* Overrides Drupal\Core\Updater\Updater::postInstall().
|
* Overrides Drupal\Core\Updater\Updater::postInstall().
|
||||||
*/
|
*/
|
||||||
public function postInstall() {
|
public function postInstall() {
|
||||||
// Update the system table.
|
// Update the theme info.
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
system_rebuild_theme_data();
|
system_rebuild_theme_data();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,5 @@
|
||||||
* Implements hook_install().
|
* Implements hook_install().
|
||||||
*/
|
*/
|
||||||
function action_loop_test_install() {
|
function action_loop_test_install() {
|
||||||
db_update('system')
|
module_set_weight('action_loop_test', 1);
|
||||||
->fields(array('weight' => 1))
|
|
||||||
->condition('name', 'action_loop_test')
|
|
||||||
->execute();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,10 +217,7 @@ function block_install() {
|
||||||
// Block should go first so that other modules can alter its output
|
// Block should go first so that other modules can alter its output
|
||||||
// during hook_page_alter(). Almost everything on the page is a block,
|
// during hook_page_alter(). Almost everything on the page is a block,
|
||||||
// so before block module runs, there will not be much to alter.
|
// so before block module runs, there will not be much to alter.
|
||||||
db_update('system')
|
module_set_weight('block', -5);
|
||||||
->fields(array('weight' => -5))
|
|
||||||
->condition('name', 'block')
|
|
||||||
->execute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -958,12 +958,10 @@ function block_cache_flush() {
|
||||||
* Implements hook_rebuild().
|
* Implements hook_rebuild().
|
||||||
*/
|
*/
|
||||||
function block_rebuild() {
|
function block_rebuild() {
|
||||||
// Rehash blocks for active themes. We don't use list_themes() here,
|
foreach (list_themes() as $name => $data) {
|
||||||
// because if MAINTENANCE_MODE is defined it skips reading the database,
|
if ($data->status) {
|
||||||
// and we can't tell which themes are active.
|
_block_rehash($name);
|
||||||
$themes = db_query("SELECT name FROM {system} WHERE type = 'theme' AND status = 1");
|
}
|
||||||
foreach ($themes as $theme) {
|
|
||||||
_block_rehash($theme->name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,7 @@
|
||||||
*/
|
*/
|
||||||
function field_test_install() {
|
function field_test_install() {
|
||||||
// hook_entity_info_alter() needs to be executed as last.
|
// hook_entity_info_alter() needs to be executed as last.
|
||||||
db_update('system')
|
module_set_weight('field_test', 1);
|
||||||
->fields(array('weight' => 1))
|
|
||||||
->condition('name', 'field_test')
|
|
||||||
->execute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,10 +10,7 @@
|
||||||
*/
|
*/
|
||||||
function forum_install() {
|
function forum_install() {
|
||||||
// Set the weight of the forum.module to 1 so it is loaded after the taxonomy.module.
|
// Set the weight of the forum.module to 1 so it is loaded after the taxonomy.module.
|
||||||
db_update('system')
|
module_set_weight('forum', 1);
|
||||||
->fields(array('weight' => 1))
|
|
||||||
->condition('name', 'forum')
|
|
||||||
->execute();
|
|
||||||
// Forum topics are published by default, but do not have any other default
|
// Forum topics are published by default, but do not have any other default
|
||||||
// options set (for example, they are not promoted to the front page).
|
// options set (for example, they are not promoted to the front page).
|
||||||
// @todo Convert to default module configuration, once Node module's content
|
// @todo Convert to default module configuration, once Node module's content
|
||||||
|
|
|
@ -107,12 +107,9 @@ class HelpTest extends WebTestBase {
|
||||||
*/
|
*/
|
||||||
protected function getModuleList() {
|
protected function getModuleList() {
|
||||||
$modules = array();
|
$modules = array();
|
||||||
$result = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
|
$module_data = system_rebuild_module_data();
|
||||||
foreach ($result as $module) {
|
foreach (module_implements('help') as $module) {
|
||||||
if (file_exists($module->filename) && function_exists($module->name . '_help')) {
|
$modules[$module] = $module_data[$module]->info['name'];
|
||||||
$fullname = unserialize($module->info);
|
|
||||||
$modules[$module->name] = $fullname['name'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $modules;
|
return $modules;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,11 @@ class LocaleCompareTest extends WebTestBase {
|
||||||
// info of the locale_test and locale_test_disabled modules.
|
// info of the locale_test and locale_test_disabled modules.
|
||||||
variable_set('locale_translation_test_system_info_alter', TRUE);
|
variable_set('locale_translation_test_system_info_alter', TRUE);
|
||||||
|
|
||||||
// Check if interface translation data is collected from hook_info.
|
// Reset static system list caches to reflect info changes.
|
||||||
drupal_static_reset('locale_translation_project_list');
|
drupal_static_reset('locale_translation_project_list');
|
||||||
|
system_list_reset();
|
||||||
|
|
||||||
|
// Check if interface translation data is collected from hook_info.
|
||||||
$projects = locale_translation_project_list();
|
$projects = locale_translation_project_list();
|
||||||
$this->assertEqual($projects['locale_test']['info']['interface translation server pattern'], 'core/modules/locale/test/modules/locale_test/%project-%version.%language.po', 'Interface translation parameter found in project info.');
|
$this->assertEqual($projects['locale_test']['info']['interface translation server pattern'], 'core/modules/locale/test/modules/locale_test/%project-%version.%language.po', 'Interface translation parameter found in project info.');
|
||||||
$this->assertEqual($projects['locale_test']['name'] , 'locale_test', format_string('%key found in project info.', array('%key' => 'interface translation project')));
|
$this->assertEqual($projects['locale_test']['name'] , 'locale_test', format_string('%key found in project info.', array('%key' => 'interface translation project')));
|
||||||
|
|
|
@ -121,6 +121,13 @@ abstract class TestBase {
|
||||||
*/
|
*/
|
||||||
protected $verboseDirectory;
|
protected $verboseDirectory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The original database prefix when running inside Simpletest.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $originalPrefix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for Test.
|
* Constructor for Test.
|
||||||
*
|
*
|
||||||
|
@ -722,6 +729,13 @@ abstract class TestBase {
|
||||||
global $user, $conf;
|
global $user, $conf;
|
||||||
$language_interface = language(LANGUAGE_TYPE_INTERFACE);
|
$language_interface = language(LANGUAGE_TYPE_INTERFACE);
|
||||||
|
|
||||||
|
// When running the test runner within a test, back up the original database
|
||||||
|
// prefix and re-set the new/nested prefix in drupal_valid_test_ua().
|
||||||
|
if (drupal_valid_test_ua()) {
|
||||||
|
$this->originalPrefix = drupal_valid_test_ua();
|
||||||
|
drupal_valid_test_ua($this->databasePrefix);
|
||||||
|
}
|
||||||
|
|
||||||
// Backup current in-memory configuration.
|
// Backup current in-memory configuration.
|
||||||
$this->originalConf = $conf;
|
$this->originalConf = $conf;
|
||||||
|
|
||||||
|
@ -858,6 +872,9 @@ abstract class TestBase {
|
||||||
drupal_container($this->originalContainer);
|
drupal_container($this->originalContainer);
|
||||||
$language_interface = $this->originalLanguage;
|
$language_interface = $this->originalLanguage;
|
||||||
$GLOBALS['config_directories'] = $this->originalConfigDirectories;
|
$GLOBALS['config_directories'] = $this->originalConfigDirectories;
|
||||||
|
if (isset($this->originalPrefix)) {
|
||||||
|
drupal_valid_test_ua($this->originalPrefix);
|
||||||
|
}
|
||||||
|
|
||||||
// Restore original shutdown callbacks.
|
// Restore original shutdown callbacks.
|
||||||
$callbacks = &drupal_register_shutdown_function();
|
$callbacks = &drupal_register_shutdown_function();
|
||||||
|
|
|
@ -323,16 +323,16 @@ function simpletest_test_get_all() {
|
||||||
else {
|
else {
|
||||||
// Select all PSR-0 classes in the Tests namespace of all modules.
|
// Select all PSR-0 classes in the Tests namespace of all modules.
|
||||||
$classes = array();
|
$classes = array();
|
||||||
$system_list = db_query("SELECT name, filename FROM {system}")->fetchAllKeyed();
|
$module_data = system_rebuild_module_data();
|
||||||
|
$all_data = $module_data + system_rebuild_theme_data();
|
||||||
foreach ($system_list as $name => $filename) {
|
foreach ($all_data as $name => $data) {
|
||||||
// Build directory in which the test files would reside.
|
// Build directory in which the test files would reside.
|
||||||
$tests_dir = DRUPAL_ROOT . '/' . dirname($filename) . '/lib/Drupal/' . $name . '/Tests';
|
$tests_dir = DRUPAL_ROOT . '/' . dirname($data->filename) . '/lib/Drupal/' . $name . '/Tests';
|
||||||
// Scan it for test files if it exists.
|
// Scan it for test files if it exists.
|
||||||
if (is_dir($tests_dir)) {
|
if (is_dir($tests_dir)) {
|
||||||
$files = file_scan_directory($tests_dir, '/.*\.php/');
|
$files = file_scan_directory($tests_dir, '/.*\.php/');
|
||||||
if (!empty($files)) {
|
if (!empty($files)) {
|
||||||
$basedir = DRUPAL_ROOT . '/' . dirname($filename) . '/lib/';
|
$basedir = DRUPAL_ROOT . '/' . dirname($data->filename) . '/lib/';
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
// Convert the file name into the namespaced class name.
|
// Convert the file name into the namespaced class name.
|
||||||
$replacements = array(
|
$replacements = array(
|
||||||
|
@ -357,7 +357,7 @@ function simpletest_test_get_all() {
|
||||||
// If this test class requires a non-existing module, skip it.
|
// If this test class requires a non-existing module, skip it.
|
||||||
if (!empty($info['dependencies'])) {
|
if (!empty($info['dependencies'])) {
|
||||||
foreach ($info['dependencies'] as $module) {
|
foreach ($info['dependencies'] as $module) {
|
||||||
if (!drupal_get_filename('module', $module)) {
|
if (!isset($module_data[$module])) {
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,12 +385,10 @@ function simpletest_test_get_all() {
|
||||||
* Registers namespaces for disabled modules.
|
* Registers namespaces for disabled modules.
|
||||||
*/
|
*/
|
||||||
function simpletest_classloader_register() {
|
function simpletest_classloader_register() {
|
||||||
// Get the cached test modules list and register a test namespace for each.
|
$all_data = system_rebuild_module_data();
|
||||||
$disabled_modules = db_query("SELECT name, filename FROM {system} WHERE status = 0")->fetchAllKeyed();
|
$all_data += system_rebuild_theme_data();
|
||||||
if ($disabled_modules) {
|
foreach ($all_data as $name => $data) {
|
||||||
foreach ($disabled_modules as $name => $filename) {
|
drupal_classloader_register($name, dirname($data->filename));
|
||||||
drupal_classloader_register($name, dirname($filename));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
enabled:
|
||||||
|
system: '0'
|
|
@ -0,0 +1,2 @@
|
||||||
|
enabled:
|
||||||
|
stark: '0'
|
|
@ -7,12 +7,10 @@
|
||||||
|
|
||||||
namespace Drupal\system\Tests\Database;
|
namespace Drupal\system\Tests\Database;
|
||||||
|
|
||||||
use Drupal\simpletest\WebTestBase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Range query tests.
|
* Range query tests.
|
||||||
*/
|
*/
|
||||||
class RangeQueryTest extends WebTestBase {
|
class RangeQueryTest extends DatabaseTestBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modules to enable.
|
* Modules to enable.
|
||||||
|
@ -34,12 +32,12 @@ class RangeQueryTest extends WebTestBase {
|
||||||
*/
|
*/
|
||||||
function testRangeQuery() {
|
function testRangeQuery() {
|
||||||
// Test if return correct number of rows.
|
// Test if return correct number of rows.
|
||||||
$range_rows = db_query_range("SELECT name FROM {system} ORDER BY name", 2, 3)->fetchAll();
|
$range_rows = db_query_range("SELECT name FROM {test} ORDER BY name", 1, 3)->fetchAll();
|
||||||
$this->assertEqual(count($range_rows), 3, 'Range query work and return correct number of rows.');
|
$this->assertEqual(count($range_rows), 3, 'Range query work and return correct number of rows.');
|
||||||
|
|
||||||
// Test if return target data.
|
// Test if return target data.
|
||||||
$raw_rows = db_query('SELECT name FROM {system} ORDER BY name')->fetchAll();
|
$raw_rows = db_query('SELECT name FROM {test} ORDER BY name')->fetchAll();
|
||||||
$raw_rows = array_slice($raw_rows, 2, 3);
|
$raw_rows = array_slice($raw_rows, 1, 3);
|
||||||
$this->assertEqual($range_rows, $raw_rows, 'Range query work and return target data.');
|
$this->assertEqual($range_rows, $raw_rows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,10 @@
|
||||||
|
|
||||||
namespace Drupal\system\Tests\Database;
|
namespace Drupal\system\Tests\Database;
|
||||||
|
|
||||||
use Drupal\simpletest\WebTestBase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporary query tests.
|
* Temporary query tests.
|
||||||
*/
|
*/
|
||||||
class TemporaryQueryTest extends WebTestBase {
|
class TemporaryQueryTest extends DatabaseTestBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modules to enable.
|
* Modules to enable.
|
||||||
|
@ -43,7 +41,7 @@ class TemporaryQueryTest extends WebTestBase {
|
||||||
$this->drupalGet('database_test/db_query_temporary');
|
$this->drupalGet('database_test/db_query_temporary');
|
||||||
$data = json_decode($this->drupalGetContent());
|
$data = json_decode($this->drupalGetContent());
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$this->assertEqual($this->countTableRows("system"), $data->row_count, 'The temporary table contains the correct amount of rows.');
|
$this->assertEqual($this->countTableRows('test'), $data->row_count, 'The temporary table contains the correct amount of rows.');
|
||||||
$this->assertFalse(db_table_exists($data->table_name), 'The temporary table is, indeed, temporary.');
|
$this->assertFalse(db_table_exists($data->table_name), 'The temporary table is, indeed, temporary.');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -51,10 +49,10 @@ class TemporaryQueryTest extends WebTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now try to run two db_query_temporary() in the same request.
|
// Now try to run two db_query_temporary() in the same request.
|
||||||
$table_name_system = db_query_temporary('SELECT status FROM {system}', array());
|
$table_name_test = db_query_temporary('SELECT name FROM {test}', array());
|
||||||
$table_name_users = db_query_temporary('SELECT uid FROM {users}', array());
|
$table_name_task = db_query_temporary('SELECT pid FROM {test_task}', array());
|
||||||
|
|
||||||
$this->assertEqual($this->countTableRows($table_name_system), $this->countTableRows("system"), 'A temporary table was created successfully in this request.');
|
$this->assertEqual($this->countTableRows($table_name_test), $this->countTableRows('test'), 'A temporary table was created successfully in this request.');
|
||||||
$this->assertEqual($this->countTableRows($table_name_users), $this->countTableRows("users"), 'A second temporary table was created successfully in this request.');
|
$this->assertEqual($this->countTableRows($table_name_task), $this->countTableRows('test_task'), 'A second temporary table was created successfully in this request.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,11 +49,7 @@ class ModuleApiTest extends WebTestBase {
|
||||||
$this->assertModuleList($module_list, t('After adding a module'));
|
$this->assertModuleList($module_list, t('After adding a module'));
|
||||||
|
|
||||||
// Try to mess with the module weights.
|
// Try to mess with the module weights.
|
||||||
db_update('system')
|
module_set_weight('contact', 20);
|
||||||
->fields(array('weight' => 20))
|
|
||||||
->condition('name', 'contact')
|
|
||||||
->condition('type', 'module')
|
|
||||||
->execute();
|
|
||||||
// Reset the module list.
|
// Reset the module list.
|
||||||
system_list_reset();
|
system_list_reset();
|
||||||
// Move contact to the end of the array.
|
// Move contact to the end of the array.
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Contains Drupal\system\Tests\Module\ModuleEnable.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Drupal\system\Tests\Module;
|
||||||
|
|
||||||
|
use Drupal\simpletest\WebTestBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests module_enable().
|
||||||
|
*/
|
||||||
|
class ModuleEnable extends WebTestBase {
|
||||||
|
|
||||||
|
public static function getInfo() {
|
||||||
|
return array(
|
||||||
|
'name' => 'Module enable',
|
||||||
|
'description' => 'Tests module_enable().',
|
||||||
|
'group' => 'Module',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests enabling User module once more.
|
||||||
|
*
|
||||||
|
* Regression: The installer might enable a module twice due to automatic
|
||||||
|
* dependency resolution. A bug caused the stored weight for User module to
|
||||||
|
* be an array.
|
||||||
|
*/
|
||||||
|
function testEnableUserTwice() {
|
||||||
|
module_enable(array('user'), FALSE);
|
||||||
|
$this->assertIdentical(config('system.module')->get('enabled.user'), '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests recorded schema versions of early installed modules in the installer.
|
||||||
|
*/
|
||||||
|
function testRequiredModuleSchemaVersions() {
|
||||||
|
$version = drupal_get_installed_schema_version('system', TRUE);
|
||||||
|
$this->assertTrue($version > 0, 'System module version is > 0.');
|
||||||
|
$version = drupal_get_installed_schema_version('user', TRUE);
|
||||||
|
$this->assertTrue($version > 0, 'User module version is > 0.');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -22,19 +22,21 @@ class InfoAlterTest extends WebTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that {system}.info is rebuilt after a module that implements
|
* Tests that theme .info data is rebuild after enabling a module.
|
||||||
|
*
|
||||||
|
* Tests that info data is rebuilt after a module that implements
|
||||||
* hook_system_info_alter() is enabled. Also tests if core *_list() functions
|
* hook_system_info_alter() is enabled. Also tests if core *_list() functions
|
||||||
* return freshly altered info.
|
* return freshly altered info.
|
||||||
*/
|
*/
|
||||||
function testSystemInfoAlter() {
|
function testSystemInfoAlter() {
|
||||||
// Enable our test module. Flush all caches, which we assert is the only
|
// Enable seven and the test module.
|
||||||
// thing necessary to use the rebuilt {system}.info.
|
theme_enable(array('seven'));
|
||||||
module_enable(array('module_test'), FALSE);
|
module_enable(array('module_test'), FALSE);
|
||||||
$this->resetAll();
|
|
||||||
$this->assertTrue(module_exists('module_test'), t('Test module is enabled.'));
|
$this->assertTrue(module_exists('module_test'), t('Test module is enabled.'));
|
||||||
|
|
||||||
$info = $this->getSystemInfo('seven', 'theme');
|
// Verify that the rebuilt and altered theme info is returned.
|
||||||
$this->assertTrue(isset($info['regions']['test_region']), t('Altered theme info was added to {system}.info.'));
|
$info = system_get_info('theme', 'seven');
|
||||||
|
$this->assertTrue(isset($info['regions']['test_region']), t('Altered theme info was returned by system_get_info().'));
|
||||||
$seven_regions = system_region_list('seven');
|
$seven_regions = system_region_list('seven');
|
||||||
$this->assertTrue(isset($seven_regions['test_region']), t('Altered theme info was returned by system_region_list().'));
|
$this->assertTrue(isset($seven_regions['test_region']), t('Altered theme info was returned by system_region_list().'));
|
||||||
$system_list_themes = system_list('theme');
|
$system_list_themes = system_list('theme');
|
||||||
|
@ -43,13 +45,12 @@ class InfoAlterTest extends WebTestBase {
|
||||||
$list_themes = list_themes();
|
$list_themes = list_themes();
|
||||||
$this->assertTrue(isset($list_themes['seven']->info['regions']['test_region']), t('Altered theme info was returned by list_themes().'));
|
$this->assertTrue(isset($list_themes['seven']->info['regions']['test_region']), t('Altered theme info was returned by list_themes().'));
|
||||||
|
|
||||||
// Disable the module and verify that {system}.info is rebuilt without it.
|
// Disable the module and verify that rebuilt .info does not contain it.
|
||||||
module_disable(array('module_test'), FALSE);
|
module_disable(array('module_test'), FALSE);
|
||||||
$this->resetAll();
|
|
||||||
$this->assertFalse(module_exists('module_test'), t('Test module is disabled.'));
|
$this->assertFalse(module_exists('module_test'), t('Test module is disabled.'));
|
||||||
|
|
||||||
$info = $this->getSystemInfo('seven', 'theme');
|
$info = system_get_info('theme', 'seven');
|
||||||
$this->assertFalse(isset($info['regions']['test_region']), t('Altered theme info was removed from {system}.info.'));
|
$this->assertFalse(isset($info['regions']['test_region']), t('Altered theme info was not returned by system_get_info().'));
|
||||||
$seven_regions = system_region_list('seven');
|
$seven_regions = system_region_list('seven');
|
||||||
$this->assertFalse(isset($seven_regions['test_region']), t('Altered theme info was not returned by system_region_list().'));
|
$this->assertFalse(isset($seven_regions['test_region']), t('Altered theme info was not returned by system_region_list().'));
|
||||||
$system_list_themes = system_list('theme');
|
$system_list_themes = system_list('theme');
|
||||||
|
@ -58,20 +59,4 @@ class InfoAlterTest extends WebTestBase {
|
||||||
$list_themes = list_themes();
|
$list_themes = list_themes();
|
||||||
$this->assertFalse(isset($list_themes['seven']->info['regions']['test_region']), t('Altered theme info was not returned by list_themes().'));
|
$this->assertFalse(isset($list_themes['seven']->info['regions']['test_region']), t('Altered theme info was not returned by list_themes().'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the info array as it is stored in {system}.
|
|
||||||
*
|
|
||||||
* @param $name
|
|
||||||
* The name of the record in {system}.
|
|
||||||
* @param $type
|
|
||||||
* The type of record in {system}.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* Array of info, or FALSE if the record is not found.
|
|
||||||
*/
|
|
||||||
function getSystemInfo($name, $type) {
|
|
||||||
$raw_info = db_query("SELECT info FROM {system} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))->fetchField();
|
|
||||||
return $raw_info ? unserialize($raw_info) : FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,10 +129,10 @@ class UpdateScriptTest extends WebTestBase {
|
||||||
// Since visiting update.php triggers a rebuild of the theme system from an
|
// Since visiting update.php triggers a rebuild of the theme system from an
|
||||||
// unusual maintenance mode environment, we check that this rebuild did not
|
// unusual maintenance mode environment, we check that this rebuild did not
|
||||||
// put any incorrect information about the themes into the database.
|
// put any incorrect information about the themes into the database.
|
||||||
$original_theme_data = db_query("SELECT * FROM {system} WHERE type = 'theme' ORDER BY name")->fetchAll();
|
$original_theme_data = config('system.theme')->get('enabled');
|
||||||
$this->drupalLogin($this->update_user);
|
$this->drupalLogin($this->update_user);
|
||||||
$this->drupalGet($this->update_url, array('external' => TRUE));
|
$this->drupalGet($this->update_url, array('external' => TRUE));
|
||||||
$final_theme_data = db_query("SELECT * FROM {system} WHERE type = 'theme' ORDER BY name")->fetchAll();
|
$final_theme_data = config('system.theme')->get('enabled');
|
||||||
$this->assertEqual($original_theme_data, $final_theme_data, t('Visiting update.php does not alter the information about themes stored in the database.'));
|
$this->assertEqual($original_theme_data, $final_theme_data, t('Visiting update.php does not alter the information about themes stored in the database.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,8 +189,7 @@ abstract class UpgradePathTestBase extends WebTestBase {
|
||||||
protected function performUpgrade($register_errors = TRUE) {
|
protected function performUpgrade($register_errors = TRUE) {
|
||||||
|
|
||||||
// Load the first update screen.
|
// Load the first update screen.
|
||||||
$update_url = $GLOBALS['base_url'] . '/core/update.php';
|
$this->getUpdatePhp();
|
||||||
$this->drupalGet($update_url, array('external' => TRUE));
|
|
||||||
if (!$this->assertResponse(200)) {
|
if (!$this->assertResponse(200)) {
|
||||||
throw new Exception('Initial GET to update.php did not return HTTP 200 status.');
|
throw new Exception('Initial GET to update.php did not return HTTP 200 status.');
|
||||||
}
|
}
|
||||||
|
@ -230,7 +229,7 @@ abstract class UpgradePathTestBase extends WebTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there still are pending updates.
|
// Check if there still are pending updates.
|
||||||
$this->drupalGet($update_url, array('external' => TRUE));
|
$this->getUpdatePhp();
|
||||||
$this->drupalPost(NULL, array(), t('Continue'));
|
$this->drupalPost(NULL, array(), t('Continue'));
|
||||||
if (!$this->assertText(t('No pending updates.'), t('No pending updates at the end of the update process.'))) {
|
if (!$this->assertText(t('No pending updates.'), t('No pending updates at the end of the update process.'))) {
|
||||||
throw new Exception('update.php still shows pending updates after execution.');
|
throw new Exception('update.php still shows pending updates after execution.');
|
||||||
|
@ -264,21 +263,35 @@ abstract class UpgradePathTestBase extends WebTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force uninstall all modules from a test database, except those listed.
|
* Gets update.php without calling url().
|
||||||
*
|
*
|
||||||
* @param $modules
|
* Required since WebTestBase::drupalGet() calls t(), which calls into
|
||||||
* The list of modules to keep installed. Required core modules will
|
* system_list(), from the parent site/test runner, before update.php is even
|
||||||
* always be kept.
|
* executed.
|
||||||
|
*
|
||||||
|
* @see WebTestBase::drupalGet()
|
||||||
*/
|
*/
|
||||||
protected function uninstallModulesExcept(array $modules) {
|
protected function getUpdatePhp() {
|
||||||
$required_modules = array('block', 'dblog', 'filter', 'node', 'system', 'update', 'user');
|
$path = $GLOBALS['base_url'] . '/core/update.php';
|
||||||
|
$out = $this->curlExec(array(CURLOPT_HTTPGET => TRUE, CURLOPT_URL => $path, CURLOPT_NOBODY => FALSE));
|
||||||
|
// Ensure that any changes to variables in the other thread are picked up.
|
||||||
|
$this->refreshVariables();
|
||||||
|
|
||||||
$modules = array_merge($required_modules, $modules);
|
// Replace original page output with new output from redirected page(s).
|
||||||
|
if ($new = $this->checkForMetaRefresh()) {
|
||||||
db_delete('system')
|
$out = $new;
|
||||||
->condition('type', 'module')
|
}
|
||||||
->condition('name', $modules, 'NOT IN')
|
// @todo TestBase::verbose() cannot be called here yet, since Simpletest
|
||||||
->execute();
|
// verbose output parameters are not prepared before test execution and
|
||||||
|
// instead determined at runtime; i.e., file_create_url() calls into
|
||||||
|
// system_list(), before update.php has upgraded the system list.
|
||||||
|
// @see http://drupal.org/node/1611430
|
||||||
|
/*
|
||||||
|
$this->verbose('GET request to: ' . $path .
|
||||||
|
'<hr />Ending URL: ' . $this->getUrl() .
|
||||||
|
'<hr />' . $out);
|
||||||
|
*/
|
||||||
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1252,7 +1252,7 @@ function system_modules_uninstall($form, $form_state = NULL) {
|
||||||
$all_modules = system_rebuild_module_data();
|
$all_modules = system_rebuild_module_data();
|
||||||
$disabled_modules = array();
|
$disabled_modules = array();
|
||||||
foreach ($all_modules as $name => $module) {
|
foreach ($all_modules as $name => $module) {
|
||||||
if (empty($module->status) && $module->schema_version > SCHEMA_UNINSTALLED) {
|
if (empty($module->status) && drupal_get_installed_schema_version($name) > SCHEMA_UNINSTALLED) {
|
||||||
$disabled_modules[$name] = $module;
|
$disabled_modules[$name] = $module;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2167,10 +2167,7 @@ function hook_cache_flush() {
|
||||||
* @see drupal_flush_all_caches()
|
* @see drupal_flush_all_caches()
|
||||||
*/
|
*/
|
||||||
function hook_rebuild() {
|
function hook_rebuild() {
|
||||||
// Rehash blocks for active themes. We don't use list_themes() here,
|
$themes = list_themes();
|
||||||
// because if MAINTENANCE_MODE is defined it skips reading the database,
|
|
||||||
// and we can't tell which themes are active.
|
|
||||||
$themes = db_query("SELECT name FROM {system} WHERE type = 'theme' AND status = 1");
|
|
||||||
foreach ($themes as $theme) {
|
foreach ($themes as $theme) {
|
||||||
_block_rehash($theme->name);
|
_block_rehash($theme->name);
|
||||||
}
|
}
|
||||||
|
@ -2983,8 +2980,8 @@ function hook_update_last_removed() {
|
||||||
* - variables that the module has set using variable_set() or system_settings_form()
|
* - variables that the module has set using variable_set() or system_settings_form()
|
||||||
* - modifications to existing tables
|
* - modifications to existing tables
|
||||||
*
|
*
|
||||||
* The module should not remove its entry from the {system} table. Database
|
* The module should not remove its entry from the module configuration.
|
||||||
* tables defined by hook_schema() will be removed automatically.
|
* Database tables defined by hook_schema() will be removed automatically.
|
||||||
*
|
*
|
||||||
* The uninstall hook must be implemented in the module's .install file. It
|
* The uninstall hook must be implemented in the module's .install file. It
|
||||||
* will fire when the module gets uninstalled but before the module's database
|
* will fire when the module gets uninstalled but before the module's database
|
||||||
|
|
|
@ -510,11 +510,6 @@ function system_install() {
|
||||||
// Enable the default theme. Can't use theme_enable() this early in
|
// Enable the default theme. Can't use theme_enable() this early in
|
||||||
// installation.
|
// installation.
|
||||||
variable_set('theme_default', 'stark');
|
variable_set('theme_default', 'stark');
|
||||||
db_update('system')
|
|
||||||
->fields(array('status' => 1))
|
|
||||||
->condition('type', 'theme')
|
|
||||||
->condition('name', 'stark')
|
|
||||||
->execute();
|
|
||||||
config_install_default_config('theme', 'stark');
|
config_install_default_config('theme', 'stark');
|
||||||
|
|
||||||
// Populate the cron key variable.
|
// Populate the cron key variable.
|
||||||
|
@ -1423,75 +1418,6 @@ function system_schema() {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$schema['system'] = array(
|
|
||||||
'description' => "A list of all modules, themes, and theme engines that are or have been installed in Drupal's file system.",
|
|
||||||
'fields' => array(
|
|
||||||
'filename' => array(
|
|
||||||
'description' => 'The path of the primary file for this item, relative to the Drupal root; e.g. modules/node/node.module.',
|
|
||||||
'type' => 'varchar',
|
|
||||||
'length' => 255,
|
|
||||||
'not null' => TRUE,
|
|
||||||
'default' => '',
|
|
||||||
),
|
|
||||||
'name' => array(
|
|
||||||
'description' => 'The name of the item; e.g. node.',
|
|
||||||
'type' => 'varchar',
|
|
||||||
'length' => 255,
|
|
||||||
'not null' => TRUE,
|
|
||||||
'default' => '',
|
|
||||||
),
|
|
||||||
'type' => array(
|
|
||||||
'description' => 'The type of the item, either module, theme, or theme_engine.',
|
|
||||||
'type' => 'varchar',
|
|
||||||
'length' => 12,
|
|
||||||
'not null' => TRUE,
|
|
||||||
'default' => '',
|
|
||||||
),
|
|
||||||
'owner' => array(
|
|
||||||
'description' => "A theme's 'parent' . Can be either a theme or an engine.",
|
|
||||||
'type' => 'varchar',
|
|
||||||
'length' => 255,
|
|
||||||
'not null' => TRUE,
|
|
||||||
'default' => '',
|
|
||||||
),
|
|
||||||
'status' => array(
|
|
||||||
'description' => 'Boolean indicating whether or not this item is enabled.',
|
|
||||||
'type' => 'int',
|
|
||||||
'not null' => TRUE,
|
|
||||||
'default' => 0,
|
|
||||||
),
|
|
||||||
'bootstrap' => array(
|
|
||||||
'description' => "Boolean indicating whether this module is loaded during Drupal's early bootstrapping phase (e.g. even before the page cache is consulted).",
|
|
||||||
'type' => 'int',
|
|
||||||
'not null' => TRUE,
|
|
||||||
'default' => 0,
|
|
||||||
),
|
|
||||||
'schema_version' => array(
|
|
||||||
'description' => "The module's database schema version number. -1 if the module is not installed (its tables do not exist); 0 or the largest N of the module's hook_update_N() function that has either been run or existed when the module was first installed.",
|
|
||||||
'type' => 'int',
|
|
||||||
'not null' => TRUE,
|
|
||||||
'default' => -1,
|
|
||||||
'size' => 'small',
|
|
||||||
),
|
|
||||||
'weight' => array(
|
|
||||||
'description' => "The order in which this module's hooks should be invoked relative to other modules. Equal-weighted modules are ordered by name.",
|
|
||||||
'type' => 'int',
|
|
||||||
'not null' => TRUE,
|
|
||||||
'default' => 0,
|
|
||||||
),
|
|
||||||
'info' => array(
|
|
||||||
'description' => "A serialized array containing information from the module's .info file; keys can include name, description, package, version, core, dependencies, and php.",
|
|
||||||
'type' => 'blob',
|
|
||||||
'not null' => FALSE,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'primary key' => array('filename'),
|
|
||||||
'indexes' => array(
|
|
||||||
'system_list' => array('status', 'bootstrap', 'type', 'weight', 'name'),
|
|
||||||
'type_name' => array('type', 'name'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$schema['url_alias'] = array(
|
$schema['url_alias'] = array(
|
||||||
'description' => 'A list of URL aliases for Drupal paths; a user may visit either the source or destination path.',
|
'description' => 'A list of URL aliases for Drupal paths; a user may visit either the source or destination path.',
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
|
@ -2198,6 +2124,13 @@ function system_update_8024(&$sandbox) {
|
||||||
$sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
|
$sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove {system} table.
|
||||||
|
*/
|
||||||
|
function system_update_8025() {
|
||||||
|
db_drop_table('system');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @} End of "defgroup updates-7.x-to-8.x".
|
* @} End of "defgroup updates-7.x-to-8.x".
|
||||||
* The next series of updates should start at 9000.
|
* The next series of updates should start at 9000.
|
||||||
|
|
|
@ -2653,121 +2653,11 @@ function system_check_directory($form_element) {
|
||||||
return $form_element;
|
return $form_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the current status of an array of files in the system table.
|
|
||||||
*
|
|
||||||
* @param $files
|
|
||||||
* An array of files to check.
|
|
||||||
* @param $type
|
|
||||||
* The type of the files.
|
|
||||||
*/
|
|
||||||
function system_get_files_database(&$files, $type) {
|
|
||||||
// Extract current files from database.
|
|
||||||
$result = db_query("SELECT filename, name, type, status, schema_version, weight FROM {system} WHERE type = :type", array(':type' => $type));
|
|
||||||
foreach ($result as $file) {
|
|
||||||
if (isset($files[$file->name]) && is_object($files[$file->name])) {
|
|
||||||
$file->uri = $file->filename;
|
|
||||||
foreach ($file as $key => $value) {
|
|
||||||
if (!isset($files[$file->name]->$key)) {
|
|
||||||
$files[$file->name]->$key = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the records in the system table based on the files array.
|
|
||||||
*
|
|
||||||
* @param $files
|
|
||||||
* An array of files.
|
|
||||||
* @param $type
|
|
||||||
* The type of the files.
|
|
||||||
*/
|
|
||||||
function system_update_files_database(&$files, $type) {
|
|
||||||
$result = db_query("SELECT * FROM {system} WHERE type = :type", array(':type' => $type));
|
|
||||||
|
|
||||||
// Add all files that need to be deleted to a DatabaseCondition.
|
|
||||||
$delete = db_or();
|
|
||||||
foreach ($result as $file) {
|
|
||||||
if (isset($files[$file->name]) && is_object($files[$file->name])) {
|
|
||||||
// Keep the old filename from the database in case the file has moved.
|
|
||||||
$old_filename = $file->filename;
|
|
||||||
|
|
||||||
$updated_fields = array();
|
|
||||||
|
|
||||||
// Handle info specially, compare the serialized value.
|
|
||||||
$serialized_info = serialize($files[$file->name]->info);
|
|
||||||
if ($serialized_info != $file->info) {
|
|
||||||
$updated_fields['info'] = $serialized_info;
|
|
||||||
}
|
|
||||||
unset($file->info);
|
|
||||||
|
|
||||||
// Scan remaining fields to find only the updated values.
|
|
||||||
foreach ($file as $key => $value) {
|
|
||||||
if (isset($files[$file->name]->$key) && $files[$file->name]->$key != $value) {
|
|
||||||
$updated_fields[$key] = $files[$file->name]->$key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the record.
|
|
||||||
if (count($updated_fields)) {
|
|
||||||
db_update('system')
|
|
||||||
->fields($updated_fields)
|
|
||||||
->condition('filename', $old_filename)
|
|
||||||
->execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Indicate that the file exists already.
|
|
||||||
$files[$file->name]->exists = TRUE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// File is not found in file system, so delete record from the system table.
|
|
||||||
$delete->condition('filename', $file->filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($delete) > 0) {
|
|
||||||
// Delete all missing files from the system table, but only if the plugin
|
|
||||||
// has never been installed.
|
|
||||||
db_delete('system')
|
|
||||||
->condition($delete)
|
|
||||||
->condition('schema_version', -1)
|
|
||||||
->execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
// All remaining files are not in the system table, so we need to add them.
|
|
||||||
$query = db_insert('system')->fields(array('filename', 'name', 'type', 'owner', 'info'));
|
|
||||||
foreach ($files as &$file) {
|
|
||||||
if (isset($file->exists)) {
|
|
||||||
unset($file->exists);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$query->values(array(
|
|
||||||
'filename' => $file->uri,
|
|
||||||
'name' => $file->name,
|
|
||||||
'type' => $type,
|
|
||||||
'owner' => isset($file->owner) ? $file->owner : '',
|
|
||||||
'info' => serialize($file->info),
|
|
||||||
));
|
|
||||||
$file->type = $type;
|
|
||||||
$file->status = 0;
|
|
||||||
$file->schema_version = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$query->execute();
|
|
||||||
|
|
||||||
// If any module or theme was moved to a new location, we need to reset the
|
|
||||||
// system_list() cache or we will continue to load the old copy, look for
|
|
||||||
// schema updates in the wrong place, etc.
|
|
||||||
system_list_reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of information about enabled modules or themes.
|
* Returns an array of information about enabled modules or themes.
|
||||||
*
|
*
|
||||||
* This function returns the information from the {system} table corresponding
|
* This function returns the contents of the .info file for each enabled module
|
||||||
* to the cached contents of the .info file for each active module or theme.
|
* or theme.
|
||||||
*
|
*
|
||||||
* @param $type
|
* @param $type
|
||||||
* Either 'module' or 'theme'.
|
* Either 'module' or 'theme'.
|
||||||
|
@ -2788,9 +2678,9 @@ function system_update_files_database(&$files, $type) {
|
||||||
function system_get_info($type, $name = NULL) {
|
function system_get_info($type, $name = NULL) {
|
||||||
$info = array();
|
$info = array();
|
||||||
if ($type == 'module') {
|
if ($type == 'module') {
|
||||||
$result = db_query('SELECT name, info FROM {system} WHERE type = :type AND status = 1', array(':type' => 'module'));
|
$data = system_rebuild_module_data();
|
||||||
foreach ($result as $record) {
|
foreach (module_list() as $module) {
|
||||||
$info[$record->name] = unserialize($record->info);
|
$info[$module] = $data[$module]->info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2928,17 +2818,31 @@ function system_rebuild_module_data() {
|
||||||
// reference from system_list_reset() during the rebuild.
|
// reference from system_list_reset() during the rebuild.
|
||||||
if (!isset($modules_cache)) {
|
if (!isset($modules_cache)) {
|
||||||
$modules = _system_rebuild_module_data();
|
$modules = _system_rebuild_module_data();
|
||||||
|
$files = array();
|
||||||
ksort($modules);
|
ksort($modules);
|
||||||
system_get_files_database($modules, 'module');
|
// Add name, status, weight, and schema version.
|
||||||
system_update_files_database($modules, 'module');
|
$enabled_modules = config('system.module')->get('enabled');
|
||||||
|
$disabled_modules = config('system.module.disabled')->get();
|
||||||
|
$all_modules = $enabled_modules + $disabled_modules;
|
||||||
|
foreach ($modules as $module => $record) {
|
||||||
|
$record->name = $module;
|
||||||
|
$record->weight = isset($all_modules[$module]) ? $all_modules[$module] : 0;
|
||||||
|
$record->status = (int) isset($enabled_modules[$module]);
|
||||||
|
$record->schema_version = SCHEMA_UNINSTALLED;
|
||||||
|
$files[$module] = $record->filename;
|
||||||
|
}
|
||||||
$modules = _module_build_dependencies($modules);
|
$modules = _module_build_dependencies($modules);
|
||||||
$modules_cache = $modules;
|
$modules_cache = $modules;
|
||||||
|
|
||||||
|
// Store filenames to allow system_list() and drupal_get_filename() to
|
||||||
|
// retrieve them without having to rebuild or scan the filesystem.
|
||||||
|
state()->set('system.module.files', $files);
|
||||||
}
|
}
|
||||||
return $modules_cache;
|
return $modules_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh bootstrap column in the system table.
|
* Refreshes the list of bootstrap modules.
|
||||||
*
|
*
|
||||||
* This is called internally by module_enable/disable() to flag modules that
|
* This is called internally by module_enable/disable() to flag modules that
|
||||||
* implement hooks used during bootstrap, such as hook_boot(). These modules
|
* implement hooks used during bootstrap, such as hook_boot(). These modules
|
||||||
|
@ -2948,20 +2852,10 @@ function _system_update_bootstrap_status() {
|
||||||
$bootstrap_modules = array();
|
$bootstrap_modules = array();
|
||||||
foreach (bootstrap_hooks() as $hook) {
|
foreach (bootstrap_hooks() as $hook) {
|
||||||
foreach (module_implements($hook) as $module) {
|
foreach (module_implements($hook) as $module) {
|
||||||
$bootstrap_modules[] = $module;
|
$bootstrap_modules[$module] = drupal_get_filename('module', $module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$query = db_update('system')->fields(array('bootstrap' => 0));
|
state()->set('system.module.bootstrap', $bootstrap_modules);
|
||||||
if ($bootstrap_modules) {
|
|
||||||
db_update('system')
|
|
||||||
->fields(array('bootstrap' => 1))
|
|
||||||
->condition('name', $bootstrap_modules, 'IN')
|
|
||||||
->execute();
|
|
||||||
$query->condition('name', $bootstrap_modules, 'NOT IN');
|
|
||||||
}
|
|
||||||
$query->execute();
|
|
||||||
// Reset the cached list of bootstrap modules.
|
|
||||||
system_list_reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3093,8 +2987,27 @@ function _system_rebuild_theme_data() {
|
||||||
function system_rebuild_theme_data() {
|
function system_rebuild_theme_data() {
|
||||||
$themes = _system_rebuild_theme_data();
|
$themes = _system_rebuild_theme_data();
|
||||||
ksort($themes);
|
ksort($themes);
|
||||||
system_get_files_database($themes, 'theme');
|
// @todo This function has no business in determining/setting the status of
|
||||||
system_update_files_database($themes, 'theme');
|
// a theme, but various other functions expect it to return themes with a
|
||||||
|
// $status property. system_list() stores the return value of this function
|
||||||
|
// in state, and ensures to set/override the $status property for each theme
|
||||||
|
// based on the current config. Remove this code when themes have a proper
|
||||||
|
// installation status.
|
||||||
|
// @see http://drupal.org/node/1067408
|
||||||
|
$enabled_themes = config('system.theme')->get('enabled');
|
||||||
|
$files = array();
|
||||||
|
foreach ($themes as $name => $theme) {
|
||||||
|
$theme->status = (int) isset($enabled_themes[$name]);
|
||||||
|
$files[$name] = $theme->filename;
|
||||||
|
}
|
||||||
|
// Replace last known theme data state.
|
||||||
|
// @todo Obsolete with proper installation status for themes.
|
||||||
|
state()->set('system.theme.data', $themes);
|
||||||
|
|
||||||
|
// Store filenames to allow system_list() and drupal_get_filename() to
|
||||||
|
// retrieve them without having to rebuild or scan the filesystem.
|
||||||
|
state()->set('system.theme.files', $files);
|
||||||
|
|
||||||
return $themes;
|
return $themes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ function database_test_menu() {
|
||||||
* table should automatically dropped.
|
* table should automatically dropped.
|
||||||
*/
|
*/
|
||||||
function database_test_db_query_temporary() {
|
function database_test_db_query_temporary() {
|
||||||
$table_name = db_query_temporary('SELECT status FROM {system}', array());
|
$table_name = db_query_temporary('SELECT age FROM {test}', array());
|
||||||
return new JsonResponse(array(
|
return new JsonResponse(array(
|
||||||
'table_name' => $table_name,
|
'table_name' => $table_name,
|
||||||
'row_count' => db_select($table_name)->countQuery()->execute()->fetchField(),
|
'row_count' => db_select($table_name)->countQuery()->execute()->fetchField(),
|
||||||
|
|
|
@ -5,8 +5,5 @@
|
||||||
*/
|
*/
|
||||||
function url_alter_test_install() {
|
function url_alter_test_install() {
|
||||||
// Set the weight of this module to one higher than forum.module.
|
// Set the weight of this module to one higher than forum.module.
|
||||||
db_update('system')
|
module_set_weight('url_alter_test', 2);
|
||||||
->fields(array('weight' => 2))
|
|
||||||
->condition('name', 'url_alter_test')
|
|
||||||
->execute();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,11 +166,7 @@ class UpdateContribTest extends UpdateTestBase {
|
||||||
*/
|
*/
|
||||||
function testUpdateBaseThemeSecurityUpdate() {
|
function testUpdateBaseThemeSecurityUpdate() {
|
||||||
// Only enable the subtheme, not the base theme.
|
// Only enable the subtheme, not the base theme.
|
||||||
db_update('system')
|
theme_enable(array('update_test_subtheme'));
|
||||||
->fields(array('status' => 1))
|
|
||||||
->condition('type', 'theme')
|
|
||||||
->condition('name', 'update_test_subtheme')
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
// Define the initial state for core and the subtheme.
|
// Define the initial state for core and the subtheme.
|
||||||
$system_info = array(
|
$system_info = array(
|
||||||
|
@ -208,11 +204,13 @@ class UpdateContribTest extends UpdateTestBase {
|
||||||
function testUpdateShowDisabledThemes() {
|
function testUpdateShowDisabledThemes() {
|
||||||
$update_settings = config('update.settings');
|
$update_settings = config('update.settings');
|
||||||
// Make sure all the update_test_* themes are disabled.
|
// Make sure all the update_test_* themes are disabled.
|
||||||
db_update('system')
|
$theme_config = config('system.theme');
|
||||||
->fields(array('status' => 0))
|
foreach ($theme_config->get('enabled') as $theme => $weight) {
|
||||||
->condition('type', 'theme')
|
if (preg_match('/^update_test_/', $theme)) {
|
||||||
->condition('name', 'update_test_%', 'LIKE')
|
$theme_config->clear("enabled.$theme");
|
||||||
->execute();
|
}
|
||||||
|
}
|
||||||
|
$theme_config->save();
|
||||||
|
|
||||||
// Define the initial state for core and the test contrib themes.
|
// Define the initial state for core and the test contrib themes.
|
||||||
$system_info = array(
|
$system_info = array(
|
||||||
|
|
|
@ -66,7 +66,8 @@ function update_authorize_run_update($filetransfer, $projects) {
|
||||||
* The FileTransfer object created by authorize.php for use during this
|
* The FileTransfer object created by authorize.php for use during this
|
||||||
* operation.
|
* operation.
|
||||||
* @param string $project
|
* @param string $project
|
||||||
* The canonical project short name (e.g., {system}.name).
|
* The canonical project short name; i.e., the name of the module, theme, or
|
||||||
|
* profile.
|
||||||
* @param string $updater_name
|
* @param string $updater_name
|
||||||
* The name of the Drupal\Core\Updater\Updater class to use for installing
|
* The name of the Drupal\Core\Updater\Updater class to use for installing
|
||||||
* this project.
|
* this project.
|
||||||
|
|
Loading…
Reference in New Issue