summaryrefslogtreecommitdiff
path: root/modules
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 /modules
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 'modules')
-rw-r--r--modules/simpletest/tests/registry.test15
-rw-r--r--modules/system/system.install19
2 files changed, 21 insertions, 13 deletions
diff --git a/modules/simpletest/tests/registry.test b/modules/simpletest/tests/registry.test
index 3592ed13b..53ee3127f 100644
--- a/modules/simpletest/tests/registry.test
+++ b/modules/simpletest/tests/registry.test
@@ -73,11 +73,10 @@ class RegistryParseFilesTestCase extends DrupalWebTestCase {
file_save_data($this->$fileType->contents, $this->$fileType->fileName);
if ($fileType == 'existing_changed') {
- // Insert a record with a dodgy md5.
- $this->$fileType->fakeMD5 = md5($this->$fileType->contents . rand());
db_insert('registry_file')
->fields(array(
- 'md5' => $this->$fileType->fakeMD5,
+ 'filectime' => rand(1, 1000000),
+ 'filemtime' => rand(1, 1000000),
'filename' => $this->$fileType->fileName,
))
->execute();
@@ -107,9 +106,10 @@ class RegistryParseFilesTestCase extends DrupalWebTestCase {
$foundName = db_query('SELECT name FROM {registry} WHERE name = :name', array(':name' => $this->$fileType->$resource))->fetchField();
$this->assertTrue($this->$fileType->$resource == $foundName, t('Resource "@resource" found.', array('@resource' => $this->$fileType->$resource)));
}
- // Test that we have the right md5.
- $md5 = db_query('SELECT md5 FROM {registry_file} WHERE filename = :filename', array(':filename' => $this->$fileType->fileName))->fetchField();
- $this->assertTrue(md5($this->$fileType->contents) == $md5, t('MD5 for "@filename" matched.' . $fileType . $md5, array('@filename' => $this->$fileType->fileName)));
+ // Test that we have the right file creation and modification dates.
+ $dates = db_query('SELECT filectime, filemtime FROM {registry_file} WHERE filename = :filename', array(':filename' => $this->$fileType->fileName))->fetchObject();
+ $this->assertEqual($dates->filectime, filectime($this->$fileType->fileName), t('File creation date matches for %filename.', array('%filename' => $this->$fileType->fileName)));
+ $this->assertEqual($dates->filemtime, filemtime($this->$fileType->fileName), t('File modification date matches for %filename.', array('%filename' => $this->$fileType->fileName)));
}
}
@@ -121,7 +121,8 @@ class RegistryParseFilesTestCase extends DrupalWebTestCase {
foreach ($this->fileTypes as $fileType) {
$files[$this->$fileType->fileName] = array('module' => '', 'weight' => 0);
if ($fileType == 'existing_changed') {
- $files[$this->$fileType->fileName]['md5'] = $this->$fileType->fakeMD5;
+ $files[$this->$fileType->fileName]['filectime'] = rand(1, 1000000);
+ $files[$this->$fileType->fileName]['filemtime'] = rand(1, 1000000);
}
}
return $files;
diff --git a/modules/system/system.install b/modules/system/system.install
index 6e2465fca..5c5b19eab 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -1289,11 +1289,17 @@ function system_schema() {
'length' => 255,
'not null' => TRUE,
),
- 'md5' => array(
- 'description' => "Md5 hash of the file's contents when last parsed.",
- 'type' => 'varchar',
- 'length' => 32,
+ 'filectime' => array(
+ 'description' => "The creation time of the file when last parsed.",
+ 'type' => 'int',
'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'filemtime' => array(
+ 'description' => "The modification time of the file when last parsed.",
+ 'type' => 'int',
+ 'not null' => TRUE,
+ 'default' => 0,
),
),
'primary key' => array('filename'),
@@ -1717,8 +1723,9 @@ function system_update_7006() {
);
$schema['registry_file'] = array(
'fields' => array(
- 'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
- 'md5' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''),
+ 'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
+ 'filectime' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+ 'filemtime' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
),
'primary key' => array('filename'),
);