From 1ecf2d1326181a2526886221b0abc270133eab2f Mon Sep 17 00:00:00 2001
From: Angie Byron <webchick@24967.no-reply.drupal.org>
Date: Sun, 13 Jun 2010 18:27:39 +0000
Subject: [PATCH] #808162 by carlos8f, agentrickard: Fixed update.php fails
 when optional modules disabled.

---
 modules/system/system.install |  4 ++--
 modules/system/system.test    | 25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/modules/system/system.install b/modules/system/system.install
index 654ca4ac7ac2..9a57f1bc97e2 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -364,8 +364,8 @@ function system_requirements($phase) {
   if ($phase == 'update') {
     $files = system_rebuild_module_data();
     foreach ($files as $module => $file) {
-      // Ignore disabled modules.
-      if (!$file->status) {
+      // Ignore disabled modules and install profiles.
+      if (!$file->status || preg_match('/\.profile$/', $file->filename)) {
         continue;
       }
       // Check the module's PHP version.
diff --git a/modules/system/system.test b/modules/system/system.test
index b86626453772..c3aced0176ff 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -1739,6 +1739,31 @@ class UpdateScriptFunctionalTest extends DrupalWebTestCase {
     $this->assertResponse(200);
   }
 
+  /**
+   * Tests the detection of requirements for the update script to proceed.
+   */
+  function testUpdateRequirements() {
+    $this->drupalLogin($this->update_user);
+    $this->drupalGet($this->update_url, array('external' => TRUE));
+    $this->assertResponse(200);
+    // Test if disabling a module that another enabled module depends on will
+    // prevent the update from proceeding.
+    module_disable(array('block'), FALSE);
+    $this->assertFalse(module_exists('block'), t('Block module is disabled.'));
+    $this->assertTrue(module_exists('dashboard'), t('Dashboard module is enabled.'));
+    $this->drupalGet($this->update_url, array('external' => TRUE));
+    $this->assertText(t('Unresolved dependency'), t('The update process cannot proceed when a module dependency is not enabled.'));
+
+    // Test if modules required by the current install profile are not required
+    // to be enabled for an update to proceed.
+    module_enable(array('block'));
+    $this->assertTrue(module_exists('block'), t('Block module is enabled.'));
+    module_disable(array('overlay'));
+    $this->assertFalse(module_exists('overlay'), t('Overlay module is disabled.'));
+    $this->drupalGet($this->update_url, array('external' => TRUE));
+    $this->assertNoText(t('Unresolved dependency'), t('The update process can proceed when modules from the install profile are disabled.'));
+  }
+
   /**
    * Tests the effect of using the update script on the theme system.
    */
-- 
GitLab