From 520b1542ff2048840d94592ba892fb4c73788d98 Mon Sep 17 00:00:00 2001
From: Peter Lieverdink <me@cafuego.net>
Date: Tue, 14 Feb 2012 09:08:54 +1100
Subject: [PATCH 1/2] Extract and include .info file mtime when scanning filesystem.

---
 core/includes/common.inc |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/core/includes/common.inc b/core/includes/common.inc
index a4fcf51..66c570d 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -7315,6 +7315,9 @@ function drupal_parse_info_file($filename) {
     else {
       $data = file_get_contents($filename);
       $info[$filename] = drupal_parse_info_format($data);
+      // Add the info file modification time, so the modules and theme page
+      // can be sorted by the date modules or themes were added or updated.
+      $info[$filename]['mtime'] = filemtime($filename);
     }
   }
   return $info[$filename];
-- 
1.7.1


From f9ba755ec657685820999c1e29121727b5b8d2c2 Mon Sep 17 00:00:00 2001
From: Peter Lieverdink <me@cafuego.net>
Date: Tue, 14 Feb 2012 09:32:26 +1100
Subject: [PATCH 2/2] Add a test for the mtime field on module metadata.

---
 core/modules/simpletest/tests/module.test |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/core/modules/simpletest/tests/module.test b/core/modules/simpletest/tests/module.test
index c9601c9..be9e627 100644
--- a/core/modules/simpletest/tests/module.test
+++ b/core/modules/simpletest/tests/module.test
@@ -233,6 +233,21 @@ class ModuleUnitTest extends DrupalWebTestCase {
     $poll_before_forum = $poll_position !== FALSE && $forum_position !== FALSE && $poll_position < $forum_position;
     $this->assertTrue($php_before_poll && $poll_before_forum, t('Modules were enabled in the correct order by module_enable().'));
   }
+
+  /**
+   * Test whether the correct module metadata is returned.
+   */
+  function testMetaData() {
+    // Generate the list of available modules.
+    $files = system_rebuild_module_data();
+    // Check that the mtime field exists for the system module.
+    $this->assertTrue(!empty($files['system']->info['mtime']), t('The system.info modification time field is set.'));
+    // To allow for slow test systems, compare the system.info mtime with the
+    // mtime for this test file. They should not differ by more than an hour.
+    $this_mtime = filemtime(__FILE__);
+    $diff_mtime = abs($this_mtime - $files['system']->info['mtime']);
+    $this->assertTrue($diff_mtime < 3600, t('The system.info modification time field contains a valid recent timestamp.'));
+  }
 }
 
 /**
-- 
1.7.1

