summaryrefslogtreecommitdiff
path: root/includes/registry.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-07-28 12:37:54 +0000
committerDries Buytaert <dries@buytaert.net>2009-07-28 12:37:54 +0000
commitd6e113a3de6a10a512aa11342b7f82bf63a7c7e7 (patch)
tree642a76fd478918af19ad38fce04b29c5b0f01297 /includes/registry.inc
parentaab51b93194701c45e32e63be31a979c9d9754aa (diff)
downloadbrdo-d6e113a3de6a10a512aa11342b7f82bf63a7c7e7.tar.gz
brdo-d6e113a3de6a10a512aa11342b7f82bf63a7c7e7.tar.bz2
- Patch #513592 by Damien Tournoud: make it faster to rebuild the registry, mainly to improve performance of SimpleTest.
Diffstat (limited to 'includes/registry.inc')
-rw-r--r--includes/registry.inc27
1 files changed, 17 insertions, 10 deletions
diff --git a/includes/registry.inc b/includes/registry.inc
index 8efaf0f98..76c503a87 100644
--- a/includes/registry.inc
+++ b/includes/registry.inc
@@ -71,9 +71,11 @@ function _registry_rebuild() {
// or modify attributes of a file.
drupal_alter('registry_files', $files, $modules);
foreach (registry_get_parsed_files() as $filename => $file) {
- // Add the md5 to those files we've already parsed.
+ // Add the file creation and modification dates to those files we have
+ // already parsed.
if (isset($files[$filename])) {
- $files[$filename]['md5'] = $file['md5'];
+ $files[$filename]['filectime'] = $file['filectime'];
+ $files[$filename]['filemtime'] = $file['filemtime'];
}
else {
// Flush the registry of resources in files that are no longer on disc
@@ -131,18 +133,23 @@ function registry_get_parsed_files() {
function _registry_parse_files($files) {
$parsed_files = array();
foreach ($files as $filename => $file) {
- $contents = file_get_contents($filename);
- $md5 = md5($contents);
- $new_file = !isset($file['md5']);
- if ($new_file || $md5 != $file['md5']) {
+ $filectime = filectime($filename);
+ $filemtime = filemtime($filename);
+ $modified_file = !isset($file['filectime']) || !isset($file['filemtime'])
+ || $filectime != $file['filectime'] || $filemtime != $file['filemtime'];
+ if ($modified_file) {
+ $contents = file_get_contents($filename);
$parsed_files[] = $filename;
- // We update the md5 after we've saved the files resources rather than here, so if we
- // don't make it through this rebuild, the next run will reparse the file.
+ // We update the filectime/filemtime after we've saved the files resources
+ // rather than here, so if we don't make it through this rebuild, the next
+ // run will reparse the file.
_registry_parse_file($filename, $contents, $file['module'], $file['weight']);
- $file['md5'] = $md5;
db_merge('registry_file')
->key(array('filename' => $filename))
- ->fields(array('md5' => $md5))
+ ->fields(array(
+ 'filectime' => $filectime,
+ 'filemtime' => $filemtime,
+ ))
->execute();
}
}