Issue #1470656 by Damien Tournoud, amateescu: Fixed Registry rebuild should not parse the same file twice in the same request.
parent
42251b6b25
commit
42e17a1499
|
@ -29,6 +29,11 @@ function _registry_update() {
|
||||||
$connection_info = Database::getConnectionInfo();
|
$connection_info = Database::getConnectionInfo();
|
||||||
$driver = $connection_info['default']['driver'];
|
$driver = $connection_info['default']['driver'];
|
||||||
|
|
||||||
|
// During the first registry rebuild in a request, we check all the files.
|
||||||
|
// During subsequent rebuilds, we only add new files. It makes the rebuilding
|
||||||
|
// process faster during installation of modules.
|
||||||
|
static $check_existing_files = TRUE;
|
||||||
|
|
||||||
// Get current list of modules and their files.
|
// Get current list of modules and their files.
|
||||||
$modules = db_query("SELECT * FROM {system} WHERE type = 'module'")->fetchAll();
|
$modules = db_query("SELECT * FROM {system} WHERE type = 'module'")->fetchAll();
|
||||||
// Get the list of files we are going to parse.
|
// Get the list of files we are going to parse.
|
||||||
|
@ -59,8 +64,15 @@ function _registry_update() {
|
||||||
foreach (registry_get_parsed_files() as $filename => $file) {
|
foreach (registry_get_parsed_files() as $filename => $file) {
|
||||||
// Add the hash for those files we have already parsed.
|
// Add the hash for those files we have already parsed.
|
||||||
if (isset($files[$filename])) {
|
if (isset($files[$filename])) {
|
||||||
|
if ($check_existing_files) {
|
||||||
$files[$filename]['hash'] = $file['hash'];
|
$files[$filename]['hash'] = $file['hash'];
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Ignore that file for this request, it has been parsed previously
|
||||||
|
// and it is unlikely it has changed.
|
||||||
|
unset($files[$filename]);
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// Flush the registry of resources in files that are no longer on disc
|
// Flush the registry of resources in files that are no longer on disc
|
||||||
// or are in files that no installed modules require to be parsed.
|
// or are in files that no installed modules require to be parsed.
|
||||||
|
@ -95,6 +107,10 @@ function _registry_update() {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// During the next run in this request, don't bother re-checking existing
|
||||||
|
// files.
|
||||||
|
$check_existing_files = FALSE;
|
||||||
|
|
||||||
// We have some unchanged resources, warm up the cache - no need to pay
|
// We have some unchanged resources, warm up the cache - no need to pay
|
||||||
// for looking them up again.
|
// for looking them up again.
|
||||||
if (count($unchanged_resources) > 0) {
|
if (count($unchanged_resources) > 0) {
|
||||||
|
|
Loading…
Reference in New Issue