diff -u b/includes/bootstrap.inc b/includes/bootstrap.inc --- b/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -828,15 +828,15 @@ * @param $filename * The filename of the item if it is to be set explicitly rather * than by consulting the database. - * @param boolean $create_errors - * Whether to create an error when a file is missing / moved. Defaults to + * @param bool $trigger_error + * Whether to trigger an error when a file is missing / moved. Defaults to * TRUE, but we may want to set this to FALSE if we merely want to check * whether an item is installed. * * @return * The filename of the requested item or NULL if the item is not found. */ -function drupal_get_filename($type, $name, $filename = NULL, $create_errors = TRUE) { +function drupal_get_filename($type, $name, $filename = NULL, $trigger_error = TRUE) { // The location of files will not change during the request, so do not use // drupal_static(). // The $files static variable will hold the locations of all requested files. @@ -896,16 +896,16 @@ // Fall back to searching the filesystem if the database could not find the // file or the file does not exist at the path returned by the database. if (!isset($files[$type][$name])) { - $files[$type][$name] = _drupal_get_filename_fallback($type, $name, $create_errors); + $files[$type][$name] = _drupal_get_filename_fallback($type, $name, $trigger_error); } } if (isset($files[$type][$name])) { // We found a file. $file_scans = &drupal_static('_drupal_get_filename_fallback'); - // If this file had previously been marked as missing or moved, clean up - // the entry from the file scan cache. - if (isset($file_scans[$type][$name])) { + // If this file had previously been marked as missing, clean up the entry + // from the file scan cache. + if (isset($file_scans[$type][$name]) && $file_scans[$type][$name] === FALSE) { $file_scans[$type][$name] = NULL; $file_scans['#write_cache'] = TRUE; } @@ -925,13 +925,13 @@ * The type of the item (theme, theme_engine, module, profile). * @param string $name * The name of the item for which the filename is requested. - * @param boolean $create_errors + * @param bool $trigger_error * Whether to create an error when a file is missing or moved. * * @return string * The filename of the requested item or NULL if the item is not found. */ -function _drupal_get_filename_fallback($type, $name, $create_errors) { +function _drupal_get_filename_fallback($type, $name, $trigger_error) { // This static variable will hold all missing and moved files, in order // to prevent unnecessary file scans. It is an associative array with as // keys the type and name of the item, and as value: @@ -982,14 +982,14 @@ if (isset($system_filepaths[$type][$name]) && $system_filepaths[$type][$name] != $filename_from_file_scan) { // Make sure our change to the file scan cache will be written to // the persistent cache. - if ($file_scans[$type][$name] != $filename_from_file_scan) { + if (!isset($file_scans[$type][$name]) || isset($file_scans[$type][$name]) && $file_scans[$type][$name] != $filename_from_file_scan) { $file_scans['#write_cache'] = TRUE; } // This file has moved. Store its new location in the file scan cache. $file_scans[$type][$name] = $filename_from_file_scan; // Create a user-level warning about the moved file. - if ($create_errors) { - _drupal_get_filename_fallback_create_error($type, $name, 'moved'); + if ($trigger_error) { + _drupal_get_filename_fallback_trigger_error($type, $name, 'moved'); } } return $filename_from_file_scan; @@ -1003,8 +1003,8 @@ // Mark the file as missing. $file_scans[$type][$name] = FALSE; // Create a user-level warning about the missing file. - if ($create_errors) { - _drupal_get_filename_fallback_create_error($type, $name, 'missing'); + if ($trigger_error) { + _drupal_get_filename_fallback_trigger_error($type, $name, 'missing'); } } } @@ -1022,17 +1022,17 @@ * @param $error_type * The type of the error ('missing' or 'moved'). */ -function _drupal_get_filename_fallback_create_error($type, $name, $error_type) { +function _drupal_get_filename_fallback_trigger_error($type, $name, $error_type) { // Make sure we only show any missing/moved file error only once per request. - static $errors_created = array(); - if (empty($errors_created[$type][$name][$error_type])) { + static $errors_triggered = array(); + if (empty($errors_triggered[$type][$name][$error_type])) { if ($error_type == 'missing') { trigger_error(format_string('The following %type is missing from the file system: %name. In order to fix this, put the file back in its original location or uninstall the module. For more information, see the documentation page.', array('%type' => $type, '%name' => $name, '@documentation' => 'https://www.drupal.org/node/2487215')), E_USER_WARNING); } elseif ($error_type == 'moved') { - trigger_error(format_string('The following %type has moved on the file system: %name. In order to fix this, clear caches or put the file back in its original location. For more information, see the documentation page.', array('%type' => $type, '%name' => $name, '@documentation' => 'https://www.drupal.org/node/2487215')), E_USER_WARNING); + trigger_error(format_string('The following %type has moved within the file system: %name. In order to fix this, clear caches or put the file back in its original location. For more information, see the documentation page.', array('%type' => $type, '%name' => $name, '@documentation' => 'https://www.drupal.org/node/2487215')), E_USER_WARNING); } - $errors_created[$type][$name][$error_type] = TRUE; + $errors_triggered[$type][$name][$error_type] = TRUE; } }