The code in the _block_rehash() function is capable of disabling all blocks for a particular theme, if it ever tries to rehash blocks for a theme it doesn't recognize.

We have seen this happen occasionally on some Drupal 7 sites.

Although I'm trying to look a little deeper into the root cause of the bug, it also occurred to me that even inside _block_rehash(), there is perhaps no good reason ever to do this. The intention of the code that disables the blocks is that if (for example) a theme is changed so that it no longer contains certain regions, the blocks that were in that region should be disabled so they can be placed somewhere else. That's all fine, but a theme without any regions doesn't make sense, so if _block_rehash() comes across a theme that appears to be in that situation, it seems reasonable for it to catch that case and not blindly disable every single one of the theme's blocks.

The attached patch makes that change.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

Looks ok

effulgentsia’s picture

The patch looks reasonable, and I don't believe it would hurt HEAD, so no harm in committing it. But I don't like the mystery of it all. What actually causes $regions to be empty? A theme .info file without any 'regions' lines would do it, but like you said, that's a rare condition, so I doubt that's what led to this being observed on real sites. I'd rather a test be created that identifies a real condition of this occurring. Perhaps we need to exit out of the function earlier if we're passed a questionable $theme variable?

+++ modules/block/block.module	28 Sep 2010 15:48:50 -0000
@@ -428,10 +428,11 @@ function _block_rehash($theme = NULL) {
+      // Blocks which are assigned to an invalid region inside a valid theme
+      // (for example, if the theme no longer defines the region the block was
+      // previously placed in) should be disabled.

Alternate wording suggestion:

A block assigned to a region that isn't implemented by the theme is effectively disabled, so set the status accordingly, rather than leaving it orphaned. This commonly occurs during development, when a theme is updated to no longer implement a region that it used to. If the theme doesn't implement any regions, it's indicative of some error, such as a corrupt .info file. In this case, do not disable every block.

Bonus if we also dsm() and/or watchdog() the condition.

Powered by Dreditor.

effulgentsia’s picture

Title: Block module should never disable all blocks for a theme » Block module sometimes disables all blocks (root cause not yet found)
David_Rothstein’s picture

In my opinion the root cause is probably #925490: list_themes() should not call file_exists() on each theme's info file which would be difficult to test.

nagba’s picture

Rerolling the patch against Drupal 7.16-dev.

effulgentsia’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work
Issue tags: +Needs backport to D7

Thanks, but bug fixes need to get into the version of Drupal that's in development first, then backported to released versions. Otherwise, it's too easy to forget to forward port, and then we end up with regressions when people upgrade from 7 to 8.

dcam’s picture

Status: Needs work » Needs review
FileSize
1.25 KB

Ported #5 to D8.

dcam’s picture

Status: Needs review » Needs work

The last submitted patch, prevent-disable-all-blocks-925360-7.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

roderik’s picture

FWIW: reroll for 7.56 (and 7.55). Only the diff context changed.

Also: I believe the backport tag stays on the issue until the D7 patch is actually committed.

dcam’s picture

It does stay. I wouldn't normally have removed that tag arbitrarily, even 5 years ago. It probably happened accidentally.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

pameeela’s picture

Version: 8.9.x-dev » 9.3.x-dev
Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Bug Smash Initiative

I do recall seeing this in D7 at times but have never seen it in D8. Anyone know if it's still relevant?

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

@David_Rothstein, Thank you for reporting this problem.

There has been no discussion of the problem stated in the IS for 5 years and no reports of this happening on Drupal 8+

If you are experiencing this problem on a supported version of Drupal, provide complete steps to reproduce the issue (starting from "Install Drupal core").

Since we need more information to move forward with this issue, I am keeping the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

There are no reports of this in Drupal 8+, so time to close this one.