diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-07-10 01:57:32 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-07-10 01:57:32 +0000 |
commit | 3e44e9eed677f71329bbdcdfe6db4032578c9111 (patch) | |
tree | 448584d2c6a694da01028f56d7aa1d8bf154fb94 /includes/registry.inc | |
parent | 57ab633bc52c08aacc0463d496ff09f034e0f8d1 (diff) | |
download | brdo-3e44e9eed677f71329bbdcdfe6db4032578c9111.tar.gz brdo-3e44e9eed677f71329bbdcdfe6db4032578c9111.tar.bz2 |
- Patch #819388 by pwolanin: switch registry back to using hashes not file mtime and ctime.
Diffstat (limited to 'includes/registry.inc')
-rw-r--r-- | includes/registry.inc | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/includes/registry.inc b/includes/registry.inc index 7b54e4833..9a12e393f 100644 --- a/includes/registry.inc +++ b/includes/registry.inc @@ -65,11 +65,9 @@ function _registry_update() { // or modify attributes of a file. drupal_alter('registry_files', $files, $modules); foreach (registry_get_parsed_files() as $filename => $file) { - // Add the file creation and modification dates to those files we have - // already parsed. + // Add the hash for those files we have already parsed. if (isset($files[$filename])) { - $files[$filename]['filectime'] = $file['filectime']; - $files[$filename]['filemtime'] = $file['filemtime']; + $files[$filename]['hash'] = $file['hash']; } else { // Flush the registry of resources in files that are no longer on disc @@ -129,22 +127,15 @@ function registry_get_parsed_files() { */ function _registry_parse_files($files) { $parsed_files = array(); - $filetimes = array(); foreach ($files as $filename => $file) { if (file_exists($filename)) { - $filetimes[$filename] = array( - 'filectime' => filectime($filename), - 'filemtime' => filemtime($filename), - ); - - $modified_file = !isset($file['filectime']) || !isset($file['filemtime']) - || $filetimes[$filename]['filectime'] != $file['filectime'] - || $filetimes[$filename]['filemtime'] != $file['filemtime']; - if ($modified_file) { + $hash = hash_file('sha256', $filename); + if (empty($file['hash']) || $file['hash'] != $hash) { // Delete registry entries for this file, so we can insert the new resources. db_delete('registry') ->condition('filename', $filename) ->execute(); + $file['hash'] = $hash; $parsed_files[$filename] = $file; } } @@ -154,8 +145,7 @@ function _registry_parse_files($files) { db_merge('registry_file') ->key(array('filename' => $filename)) ->fields(array( - 'filectime' => $filetimes[$filename]['filectime'], - 'filemtime' => $filetimes[$filename]['filemtime'], + 'hash' => $file['hash'], )) ->execute(); } |