Index: update.php
===================================================================
RCS file: /cvs/drupal/drupal/update.php,v
retrieving revision 1.225
diff -u -p -r1.225 update.php
--- update.php	8 Jun 2007 05:50:53 -0000	1.225
+++ update.php	27 Jun 2007 07:53:51 -0000
@@ -722,7 +722,8 @@ function update_fix_compatibility() {
     }
     if (!isset($file)
         || !isset($file->info['core'])
-        || $file->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
+        || $file->info['core'] != DRUPAL_CORE_COMPATIBILITY
+        || ($file->type == 'module' && version_compare(phpversion(), $file->info['php']) < 0)) {
       $incompatible[] = $name;
     }
   }
Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.102
diff -u -p -r1.102 module.inc
--- includes/module.inc	25 May 2007 12:46:43 -0000	1.102
+++ includes/module.inc	27 Jun 2007 07:53:52 -0000
@@ -107,7 +107,8 @@ function module_rebuild_cache() {
     'dependencies' => array(),
     'dependents' => array(),
     'description' => '',
-    'version' => NULL
+    'version' => NULL,
+    'php' => DRUPAL_MINIMUM_PHP,
   );
 
   foreach ($files as $filename => $file) {
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.496
diff -u -p -r1.496 system.module
--- modules/system/system.module	24 Jun 2007 10:09:53 -0000	1.496
+++ modules/system/system.module	27 Jun 2007 07:53:52 -0000
@@ -1476,7 +1476,8 @@ function system_modules($form_state = ar
   // Array for disabling checkboxes in callback system_module_disable.
   $disabled = array();
   $throttle = array();
-  $incompatible = array();
+  $incompatible_core = array();
+  $incompatible_php = array();
   // Traverse the files retrieved and build the form.
   foreach ($files as $filename => $file) {
     $form['name'][$filename] = array('#value' => $file->info['name']);
@@ -1485,7 +1486,14 @@ function system_modules($form_state = ar
     $options[$filename] = '';
     // Ensure this module is compatible with this version of core.
     if (!isset($file->info['core']) || $file->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
-      $incompatible[] = $file->name;
+      $incompatible_core[] = $file->name;
+      $disabled[] = $file->name;
+      // Nothing else in this loop matters, so move to the next module.
+      continue;
+    }
+    // Ensure this module is compatible with the currently installed version of PHP.
+    if (version_compare(phpversion(), $file->info['php']) < 0) {
+      $incompatible_php[] = $file->name;
       $disabled[] = $file->name;
       // Nothing else in this loop matters, so move to the next module.
       continue;
@@ -1567,7 +1575,8 @@ function system_modules($form_state = ar
       'system_modules_disable',
     ),
     '#disabled_modules' => $disabled,
-    '#incompatible_modules' => drupal_map_assoc($incompatible),
+    '#incompatible_modules_core' => drupal_map_assoc($incompatible_core),
+    '#incompatible_modules_php' => drupal_map_assoc($incompatible_php),
   );
 
   // Handle throttle checkboxes, including overriding the
@@ -1816,11 +1825,16 @@ function theme_system_modules($form) {
     foreach ($modules as $key => $module) {
       $row = array();
       $description = drupal_render($form['description'][$key]);
-      if (isset($form['status']['#incompatible_modules'][$key])) {
+      if (isset($form['status']['#incompatible_modules_core'][$key])) {
         unset($form['status'][$key]);
         $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of Drupal core'));
         $description .= '<div class="incompatible">'. t('This version is incompatible with the !core_version version of Drupal core.', array('!core_version' => VERSION)) .'</div>';
       }
+      elseif (isset($form['status']['#incompatible_modules_php'][$key])) {
+        unset($form['status'][$key]);
+        $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of PHP'));
+        $description .= '<div class="incompatible">'. t('This module is incompatible with PHP version !php_version.', array('!php_version' => phpversion())) .'</div>';
+      }
       else {
         $status = drupal_render($form['status'][$key]);
       }
