Commit 206c7c1b authored by Fabianx's avatar Fabianx

Issue #1081266 by stefan.r, jeroen.b, mikeytown2, David_Rothstein, tsphethean,...

Issue #1081266 by stefan.r, jeroen.b, mikeytown2, David_Rothstein, tsphethean, mfb, joseph.olstad, marcelovani, Kars-T, joelpittet, Fabianx, catch, fgm, das-peter, alexpott, emcniece, oriol_e9g, sun, corbacho, klausi, mgifford, onelittleant, Peter Bex, Spleshka, beejeebus, Berdir, pwaterz, SocialNicheGuru, sylus, Wim Leers, heyyo, joshtaylor, swentel, alanburke, dagmar, alexmoreno, kenorb, EvanSchisler, Mark Theunissen, bmateus, andypost, Lukas von Blarer, ChristophWeber, nicholas.alipaz, arosboro, askibinski, dawehner, DerekL, ExTexan: Avoid re-scanning module directory when a filename or a module is missing
parent f68a354f
......@@ -52,6 +52,7 @@ Drupal 7.50, xxxx-xx-xx (development version)
data structure change).
- Increased maxlength of menu link title input fields in the node form and
menu link form from 128 to 255 characters.
- Avoid re-scanning of module directory when a filename or a module is missing.
Drupal 7.44, 2016-06-15
-----------------------
......
This diff is collapsed.
......@@ -2776,6 +2776,7 @@ function drupal_page_footer() {
_registry_check_code(REGISTRY_WRITE_LOOKUP_CACHE);
drupal_cache_system_paths();
module_implements_write_cache();
drupal_file_scan_write_cache();
system_run_automated_cron();
}
......
......@@ -199,7 +199,16 @@ function _drupal_log_error($error, $fatal = FALSE) {
$number++;
}
watchdog('php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);
// Log the error immediately, unless this is a non-fatal error which has been
// triggered via drupal_trigger_error_with_delayed_logging(); in that case
// trigger it in a shutdown function. Fatal errors are always triggered
// immediately since for a fatal error the page request will end here anyway.
if (!$fatal && drupal_static('_drupal_trigger_error_with_delayed_logging')) {
drupal_register_shutdown_function('watchdog', 'php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);
}
else {
watchdog('php', '%type: !message in %function (line %line of %file).', $error, $error['severity_level']);
}
if ($fatal) {
drupal_add_http_header('Status', '500 Service unavailable (with message)');
......
......@@ -227,6 +227,10 @@ function system_list_reset() {
drupal_static_reset('list_themes');
cache_clear_all('bootstrap_modules', 'cache_bootstrap');
cache_clear_all('system_list', 'cache_bootstrap');
// Clean up the bootstrap file scan cache.
drupal_static_reset('_drupal_file_scan_cache');
cache_clear_all('_drupal_file_scan_cache', 'cache_bootstrap');
}
/**
......
......@@ -795,6 +795,14 @@ function update_fix_d7_requirements() {
function update_fix_d7_install_profile() {
$profile = drupal_get_profile();
// 'Default' profile has been renamed to 'Standard' in D7.
// We change the profile here to prevent a broken record in the system table.
// See system_update_7049().
if ($profile == 'default') {
$profile = 'standard';
variable_set('install_profile', $profile);
}
$results = db_select('system', 's')
->fields('s', array('name', 'schema_version'))
->condition('name', $profile)
......
......@@ -374,7 +374,10 @@ function simpletest_test_get_all() {
// If this test class requires a non-existing module, skip it.
if (!empty($info['dependencies'])) {
foreach ($info['dependencies'] as $module) {
if (!drupal_get_filename('module', $module)) {
// Pass FALSE as fourth argument so no error gets created for
// the missing file.
$found_module = drupal_get_filename('module', $module, NULL, FALSE);
if (!$found_module) {
continue 2;
}
}
......
This diff is collapsed.
<?php
/**
* @file
* Install, update and uninstall functions for the system_test module.
*/
/**
* Implements hook_schema().
*/
function system_test_schema() {
// Trigger a search for a module in the filesystem when requested by
// system_test_drupal_get_filename_with_schema_rebuild().
if (variable_get('system_test_drupal_get_filename_attempt_recursive_rebuild')) {
$module_name = variable_get('system_test_drupal_get_filename_test_module_name');
drupal_get_filename('module', $module_name);
}
return array();
}
......@@ -127,6 +127,20 @@ function system_test_menu() {
'type' => MENU_CALLBACK,
);
$items['system-test/drupal-get-filename'] = array(
'title' => 'Test drupal_get_filename()',
'page callback' => 'system_test_drupal_get_filename',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['system-test/drupal-get-filename-with-schema-rebuild'] = array(
'title' => 'Test drupal_get_filename() with a schema rebuild',
'page callback' => 'system_test_drupal_get_filename_with_schema_rebuild',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
......@@ -482,3 +496,76 @@ function system_test_request_destination() {
// information.
exit;
}
/**
* Page callback to run drupal_get_filename() on a particular module.
*/
function system_test_drupal_get_filename() {
// Prevent SimpleTest from failing as a result of the expected PHP warnings
// this function causes. Any warnings will be recorded in the database logs
// for examination by the tests.
define('SIMPLETEST_COLLECT_ERRORS', FALSE);
$module_name = variable_get('system_test_drupal_get_filename_test_module_name');
drupal_get_filename('module', $module_name);
return '';
}
/**
* Page callback to run drupal_get_filename() and do a schema rebuild.
*/
function system_test_drupal_get_filename_with_schema_rebuild() {
// Prevent SimpleTest from failing as a result of the expected PHP warnings
// this function causes.
define('SIMPLETEST_COLLECT_ERRORS', FALSE);
// Record the original database tables from drupal_get_schema().
variable_set('system_test_drupal_get_filename_with_schema_rebuild_original_tables', array_keys(drupal_get_schema(NULL, TRUE)));
// Trigger system_test_schema() and system_test_watchdog() to perform an
// attempted recursive rebuild when drupal_get_schema() is called. See
// BootstrapGetFilenameWebTestCase::testRecursiveRebuilds().
variable_set('system_test_drupal_get_filename_attempt_recursive_rebuild', TRUE);
drupal_get_schema(NULL, TRUE);
return '';
}
/**
* Implements hook_watchdog().
*/
function system_test_watchdog($log_entry) {
// If an attempted recursive schema rebuild has been triggered by
// system_test_drupal_get_filename_with_schema_rebuild(), perform the rebuild
// in response to the missing file message triggered by system_test_schema().
if (!variable_get('system_test_drupal_get_filename_attempt_recursive_rebuild')) {
return;
}
if ($log_entry['type'] != 'php' || $log_entry['severity'] != WATCHDOG_WARNING) {
return;
}
$module_name = variable_get('system_test_drupal_get_filename_test_module_name');
if (!isset($log_entry['variables']['!message']) || strpos($log_entry['variables']['!message'], format_string('The following module is missing from the file system: %name', array('%name' => $module_name))) === FALSE) {
return;
}
variable_set('system_test_drupal_get_filename_with_schema_rebuild_final_tables', array_keys(drupal_get_schema()));
}
/**
* Implements hook_module_implements_alter().
*/
function system_test_module_implements_alter(&$implementations, $hook) {
// For BootstrapGetFilenameWebTestCase::testRecursiveRebuilds() to work
// correctly, this module's hook_schema() implementation cannot be either the
// first implementation (since that would trigger a potential recursive
// rebuild before anything is in the drupal_get_schema() cache) or the last
// implementation (since that would trigger a potential recursive rebuild
// after the cache is already complete). So put it somewhere in the middle.
if ($hook == 'schema') {
$group = $implementations['system_test'];
unset($implementations['system_test']);
$count = count($implementations);
$implementations = array_merge(array_slice($implementations, 0, $count / 2, TRUE), array('system_test' => $group), array_slice($implementations, $count / 2, NULL, TRUE));
}
}
......@@ -24,7 +24,7 @@ class ModuleUpdater extends Updater implements DrupalUpdaterInterface {
* found on your system, and if there was a copy in sites/all, we'd see it.
*/
public function getInstallDirectory() {
if ($relative_path = drupal_get_path('module', $this->name)) {
if ($this->isInstalled() && ($relative_path = drupal_get_path('module', $this->name))) {
$relative_path = dirname($relative_path);
}
else {
......@@ -34,7 +34,7 @@ public function getInstallDirectory() {
}
public function isInstalled() {
return (bool) drupal_get_path('module', $this->name);
return (bool) drupal_get_filename('module', $this->name, NULL, FALSE);
}
public static function canUpdateDirectory($directory) {
......@@ -109,7 +109,7 @@ class ThemeUpdater extends Updater implements DrupalUpdaterInterface {
* found on your system, and if there was a copy in sites/all, we'd see it.
*/
public function getInstallDirectory() {
if ($relative_path = drupal_get_path('theme', $this->name)) {
if ($this->isInstalled() && ($relative_path = drupal_get_path('theme', $this->name))) {
$relative_path = dirname($relative_path);
}
else {
......@@ -119,7 +119,7 @@ public function getInstallDirectory() {
}
public function isInstalled() {
return (bool) drupal_get_path('theme', $this->name);
return (bool) drupal_get_filename('theme', $this->name, NULL, FALSE);
}
static function canUpdateDirectory($directory) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment