Problem
The new method function block_flush_caches()
in block.module in drupal 6.22 [#8] (D7 & D8 included) iterates through all active themes with _block_rehash($theme)
. It seems that the error
The block X was assigned to the invalid region Y and has been disabled.
is thrown when an activated theme is not implementing the region Y.
This basically makes the feature, where blocks can define default regions, completely useless. As soon as you have an admin theme with less regions than your front-end theme (e.g. Seven) you get notices on every _block_rehash()
i.e. every cache clear.
This is applying to any module that provides blocks which set a default region in hook_block_info.
You can easily reproduce problem by making a new block in a custom module and assigning it to the 'invalid_region' region.
Proposed resolution(s)
I think we just remove the
drupal_set_message()
with a comment explaining that it's a perfectly valid thing to do, to assign blocks to a non-existing region. The blocks get disabled anyway, and that's expected behaviour if the region they were meant to be in, doesn't exist. [#36]
OR
Attached a patch that check the block status is set to 1, instead of removing the message completly. While assigning a block to a non-existing region is valid, having an active block assigned to an non-existing region is not, so we shall imho still issue a message in this case. [#40]
+
Checking the status node simply ensure this message will only be displayed once, whereas in current config, (under certain circumstances) you can have it displayed everytime _block_rehash() is called. [#42]
Workarounds mentioned in the issue: #8 + #22 + #24 + #31
Original report by Mamoun
Each time I clean the cache I get this message:
The block Boost: Pages cache status was assigned to the invalid region right and has been disabled.
The block Boost: Pages cache configuration was assigned to the invalid region right and has been disabled.
The block Boost: AJAX core statistics was assigned to the invalid region right and has been disabled.
The block Boost: Pages cache status was assigned to the invalid region right and has been disabled.
The block Boost: Pages cache configuration was assigned to the invalid region right and has been disabled.
The block Boost: AJAX core statistics was assigned to the invalid region right and has been disabled.
The block Boost: Pages cache status was assigned to the invalid region right and has been disabled.
The block Boost: Pages cache configuration was assigned to the invalid region right and has been disabled.
The block Boost: AJAX core statistics was assigned to the invalid region right and has been disabled.
This occurred probably after updating modules, I can't however make sure of that as I have changed plenty of things in the website other than that.
Comment | File | Size | Author |
---|---|---|---|
#81 | drupal-1172560-81.patch | 1.18 KB | NROTC_Webmaster |
#77 | drupal-1172560-77-tests.patch | 2.94 KB | tim.plunkett |
#77 | drupal-1172560-77-combined.patch | 3.97 KB | tim.plunkett |
#74 | warn_for_invalid_regions-1172560-74.patch | 4.03 KB | bas.hr |
#74 | warn_for_invalid_regions-test-only-1172560-74-do-not-test.patch | 2.98 KB | bas.hr |
Comments
Comment #1
2ndmile CreditAttribution: 2ndmile commentedI am seeing the same thing. Also getting 'Can not write to file-system' in Status Report.
Comment #2
digilu CreditAttribution: digilu commentedIs this just the wrong place to post this issue? I am having the same problem. Is it a Boost issue? Theme issue? It only started to effect my site when we upgraded to 6.22
Comment #3
jmcerda CreditAttribution: jmcerda commentedsubscribing
Comment #4
ashaw4949 CreditAttribution: ashaw4949 commentedI am having the same problem for more than two weeks now. Should I disable the boost module?
Comment #5
redraven CreditAttribution: redraven commentedI am experiencing this issue also and tracked it back to the 6.22 upgrade. I'm also getting the same message for a module generated block for the station module, so it doesn't appear to be solely the boost module that is throwing this error message.
Comment #6
jamonation CreditAttribution: jamonation commentedSubscribing, seeing the same thing as redraven with other modules and 6.22 as well.
Comment #7
jaykaycgn CreditAttribution: jaykaycgn commentedsubscribing, same error message on cache clear with drupal-update to 6.22:
is there any way yet to get rid of this warning?
Comment #8
jaykaycgn CreditAttribution: jaykaycgn commentedi figured out that the new method function block_flush_caches() in block.module in drupal 6.22 iterates through all active themes with _block_rehash($theme). It seems to me that the error "The block XXX was assigned to the invalid region YYY and has been disabled." is thrown when an activated theme is not implementing the region YYY.
a var_export in _block_rehash of the $regions gives me
As you can see,
the second theme doesnt have the region right (which was the Region with errors for me), the first one has, i already fixed this.
After that, i gave the second theme (in my case it was the zen original theme) the region "right" and the warning was gone.
Just a Wordaround but it works:
Give all your active Themes the Regions that produce the error by manipulation their theme.info-File and add the Region to the regions[]-Array.
Comment #9
kardave CreditAttribution: kardave commented+1
Comment #10
jvinci CreditAttribution: jvinci commentedsubscribing
Comment #11
ZenLax CreditAttribution: ZenLax commentedI do not currently use the Boost module, but this happened for other module blocks after upgrading to 6.22. I believe it occurred because the upgrade process requires you to switch to a default core theme while your site is offline, which may have caused the assigned regions to change.
The somewhat ugly but effective workaround I used was to manually edit the database "blocks" table to remove the offending invalid regions from the blocks in the default theme used during upgrade, which was no longer in use after the 6.22 upgrade. After removing the invalid region from the blocks, I no longer received the "assigned to the invalid region right and has been disabled" messages.
It's worth noting that I also had numerous blocks still assigned to previously deleted contributed themes. I used the sitedoc module to clean these out, though likely could have done this manually as well.
Comment #12
daniel-san CreditAttribution: daniel-san commentedI'm not using the Boost module either, but I have been having this same issue and was searching like crazy. Thank you for your post ZenLax. I went into the database and cleaned it up and it went away.
Is there some other place that we need to post this information?
Dan
Comment #13
Gill Xu CreditAttribution: Gill Xu commented+1
Comment #14
mrothmay CreditAttribution: mrothmay commentedSubscribing
Comment #15
niteshshukla CreditAttribution: niteshshukla commentedPlease create all the regions in theme.info file,then it will be work.
thnks,
Comment #16
jvieille CreditAttribution: jvieille commentedThis is a core bug in 6.22, isn't it?
I have the same problem with the File Framework module
May be this needs to be directed to the Drupal 6 project?
Comment #17
SergFromSD CreditAttribution: SergFromSD commentedI've been having the same problem and cleaning the blocks table only fixes the problem until the next time I either clear the block cache or go to /admin/build/block/instances. Then the same offending entries are written back to the block table. Tried adding the offending regions the the theme.info file and that did not fix it either. This makes 6.22 an upgrade that is not very usable so I'll have to stay with an older "unsecure version". Has any one come up with a solution that works????
Comment #18
jvieille CreditAttribution: jvieille commentedI defined the "offending" region (which was "right" in my case) to my theme, and finally got quiet.
I simply duplicate a theme region, without side effect until now.
Nevertheless, 6.22 is buggy and must be fixed.
Comment #19
jvieille CreditAttribution: jvieille commentedNothing to do with Boost
Changing for a "Bug" category in "Drupal core" issue list, "Major" as it is really annoying
Comment #20
jvieille CreditAttribution: jvieille commentedComment #21
aubjr_drupal CreditAttribution: aubjr_drupal commentedTo add to #comment-4660666 (#8 above by jaykaycgn) and other posts, if there are any themes that are enabled (checked) in the Themes list, whether it's your selected theme or not, and you have blocks or other elements in a region that is not defined in ALL of the enabled themes, this error will pop up.
My selected/primary theme is a subtheme of Zen, and the subtheme has a region left that's not in Zen and I was getting the error. I had to disable/uncheck Zen to get the errors to stop. (I didn't want to edit Zen and add the offending regions to stop the errors as others have suggested because I don't maintain Zen and didn't want to have to re-apply the changes anytime I update it.)
This is definitely a bug that should be fixed because you'd expect this kind of region checking behavior for only the selected theme and no others, including parent themes like Zen.
Comment #22
jvieille CreditAttribution: jvieille commentedEven with only one theme enabled and the block database cleared up, the error fired.
I could only solve it by creating a fake "right" region that I hope will not break something in my theme 'I just copied the "sidebar last" code in my Acquia slate theme
Comment #23
jsibley CreditAttribution: jsibley commentedHas this been solved?
If not, in the meantime, is there a way to stop the notifications from being shown to anyone other than the administrator?
Thanks.
Comment #24
jamonation CreditAttribution: jamonation commentedI use this when deploying from a staging environment to sandboxes and production:
Not pretty, but it works for any $SITE with a drush alias.
Comment #25
atouchard CreditAttribution: atouchard commentedsubscribing
Comment #26
tribe_of_dan CreditAttribution: tribe_of_dan commentedsub this is a major hold up for me... this is months old now and a major issue, is anyone working on it?
Comment #27
dmendo11 CreditAttribution: dmendo11 commentedHello guys,
I am also having the same issue and here is where I think the issue comes from. If you look at the boost.module file here is the code:
The region is calling its "right".
I am currently using Acquia Propser and the region doesn't exist.
So I know where the code is coming from, but what can we do to change this issue on every empty cache we do.
Help is needed!
David
Comment #28
tstoecklerI've hit this with D7.8. I strongly suspect this in 8.x as well.
This basically makes the feature, where blocks can define default regions, completely useless. As soon as you have an admin theme with less regions than your front-end theme (*cough* Seven
*cough*) you get notices on every _block_rehash() i.e. every cache clear.
I'm not sure this is major, though. I personally like the feature very much, but it is not really widely used.
Comment #29
jvieille CreditAttribution: jvieille commentedSo it is a Boost bug?
Comment #30
tstoecklerNo it's not. It is valid for any module that provides blocks which set a default region in hook_block_info. Those aren't very many, but it's a core bug nonetheless.
Comment #31
dmendo11 CreditAttribution: dmendo11 commentedHi guys!
So I figure this out. I am no longer having this issues. So the problem is with the boost module problem. So if you have it installed, uninstall it first. You have to disable it first, then uninstall it. Then remove it from your files over the FTP. Then, make the change to the block region according to your theme. Mine was Acquia Prosper, so I made it like this:
Then reuploaded the files and installed the module again. Then it was not displaying that error any longer!
The issue is with some database settings that even if you update the file boost.module and clear cache it will still have the issue. The settings are already stored in the database and that is why is still showing those issues.
I know there is an easier way to do this on the PHPADMIN side with an SQL query, but I am not much of an expert to do this. So I guess I did it the long way. Perhaps someone can make a command to charge the "right" region in to "whatever region needs to be made. Like a template for others to use with their own theme.
Hope this helps you guys as this helped me.
David
Comment #32
mariomaric CreditAttribution: mariomaric commented@dmendo11: as reported before (#8 + #28), this is not contrib module problem, but core (block module) issue.
It would be really nice to fix this in D8 and backport to D7..although problem first emerged in D6..
Will try to write issue summary..
Comment #32.0
mariomaric CreditAttribution: mariomaric commentedAdded more info into issue summary..
Comment #33
jvieille CreditAttribution: jvieille commentedFirst D6, then D7, and finally D8 looks more appropriate.
Not many can actually use D7, with only very few stable contribs available, and D8 is not in sight for anyone at this point....
Comment #34
mariomaric CreditAttribution: mariomaric commented@jvieille: Please read Backport policy.
After this will be fixed in D8, you can add tags: Needs backport to 7.x + Needs backport to 6.x.
Comment #34.0
mariomaric CreditAttribution: mariomaric commentedFixed dead link.
Comment #34.1
mariomaric CreditAttribution: mariomaric commentedAdded info how to reproduce problem + proposed solution..
Comment #35
dcrocks CreditAttribution: dcrocks commentedI found that _block_rehash() is called in 4 places in both D7 and D8; block.admin.inc, block.module, block.test, and dashboard.module. What should be the correct behavior? Seems like 4 choices:
1) Flag as error, as is done now.
2) Set drupal_set_message( ..., FALSE) so message only sent once.
3) Skip adding the block to the theme being processed.
4) Stick the block in a convenient hole, such as the theme's default region, for the theme being processed.
On 3 and 4, what should be done with the block's enabled/disabled status? Because according to documentation, the error should be raised if the theme is the current default theme.
Comment #36
tstoecklerI think we just remove the drupal_set_message() with a comment explaining that it's a perfectly valid thing to do, to assign blocks to a non-existing region. The blocks get disabled anyway, and that's expected behaviour if the region they were meant to be in, doesn't exist.
Comment #37
dcrocks CreditAttribution: dcrocks commentedSo does anyone have anything to reproduce the error for a test?
Comment #38
tstoecklerIn a custom module (block_test.module) make a new block and assign it to the 'invalid_region' region.
Comment #39
jsibley CreditAttribution: jsibley commentedNice to see some potential action on this! Thanks.
Comment #40
bellesmanieres CreditAttribution: bellesmanieres commentedAttached a patch that check the block status is set to 1, instead of removing the message completly. While assigning a block to a non-existing region is valid, having an active block assigned to an non-existing region is not, so we shall imho still issue a message in this case.
Comment #41
tstoecklerThat's not correct.
It's the very same use-case that was discussed above. When providing defaults in hook_block_info(), you can also set its default status as 1, so that's a valid code path. Just removing the drupal_set_message() and maybe a comment should be fine.
Comment #42
bellesmanieres CreditAttribution: bellesmanieres commentedWhile yes, it is valid code to define a block in a specific region with a status of 1, seems to me it is not a valid assumption to make. It has use cases, and can be pretty convenient in a custom module geared toward a specific site, eg for zero touch deployment.
For anything contributed, I find it an invalid behavior still, in the way that it relies on assumptions on what themes (and regions) will be available or not. So think we should still warn about it, maybe in an "info" message instead of a "warning".
Checking the status node simply ensure this message will only be displayed once, whereas in current config, (under certain circumstances) you can have it displayed everytime _block_rehash() is called.
Comment #43
tstoecklerIf that is the case, then I redact my objection. I still think showing a notice for something that is really a core feature (however useful it may be) is kind of weird, but I can live with a one-time message, and I'd like others to chime in.
Comment #43.0
tstoecklerMinor change..
Comment #44
bellesmanieres CreditAttribution: bellesmanieres commentedSure, can't tell I have a very firm opinion on this anyway ;)
Comment #45
dcrocks CreditAttribution: dcrocks commentedWhat was used to test this patch?
Comment #46
ZenLax CreditAttribution: ZenLax commentedFYI I have this problem on 2 D6 sites - Boost module NEVER installed.
Comment #47
jvieille CreditAttribution: jvieille commentedThat's nice to have a patch for D8, however, it has little chance to be reviewed by the community as D8 does't even exist for most Drupalers and D7 at its very beginning.
It definitely does not help to solve the issue which appeared in Drupal 6.22 in the fist place.
I understand the policy that was referred to in #34, but it seems quite at odd with the actual situation.
Comment #48
mariomaric CreditAttribution: mariomaric commentedI can live with #40, but also agree with #43.
Adding backport tags..
@jvieille: Chances are, if you change Version for this issue to anything than D8, nobody from the core developers team will notice this issue. Or: they will have more trouble noticing it. Beside that, anybody is free to attach patch for D6 and D7, but, D8 must be resolved first according to policy.
Comment #49
jsibley CreditAttribution: jsibley commentedAny progress to report, on any version? Thanks.
Comment #50
jsibley CreditAttribution: jsibley commentedIf I understand correctly, modules may assign default regions that may not exist in some themes. Unless there is agreement between module developers and theme developers on what regions will always be available, there is a potential for this sort of problem. A particular issue is the assumption that the regions "right" and "left" will be defined, when themes such as fusion and its sub themes use sidebars.
I have no idea if this is feasible, but could a module allow site admins to map regions that are being called to regions that are actually defined in a theme, so that an admin could map "right" to "sidebar last"? Alternatively, or in addition, could admins specify through a module what should happen when a specific non existing region is called, such as "ignore, and don't write anything"?
If such a module were possible and easy to write, it might be faster than waiting for a core solution to be back ported, no?
Comment #51
jirou_ueda CreditAttribution: jirou_ueda commented#40: warn_for_invalid_regions_only_for_active_blocks-1172560-40.patch queued for re-testing.
Comment #52
NROTC_Webmaster CreditAttribution: NROTC_Webmaster commentedThe code has changed significantly and I do not think this applies for D8 (correct me if I'm wrong).
Patch for D7.
Comment #53
tstoecklerThanks for the re-roll, but this needs to be committed to D8 first. Until then please leave the version parameter at 8.x. If you want to post D7 patches, call them [whatever]-do-not-test.patch.
Comment #54
xjmAlso see the note at the bottom of http://drupal.org/node/1319154.
Tagging novice to create a D8 version of this patch as per the backport policy. We should also create an automated test that fails when the bug is present and passes with the fix applied.
Comment #55
jsibley CreditAttribution: jsibley commentedNot sure if this is the right place for this, but perhaps one way to deal with blocks assigned to non-existent regions would be to flag the issue in the site status report and to create a new report listing blocks assigned to blocks that don't exist, while ignoring these blocks when displaying the website?
Comment #56
tstoecklerMarking major now that #1373312: Assign system_main block to 'content' region and help block to 'help' region by default (followup) is in D8.
The justification is that we now have core using the 'region' key in hook_block_info(), so with every theme that does not declare a 'help' region, you will see notices on every cache clear, block admin page, etc. I realize this is arguable, because core themes all define this region, but there really is no way to make this go away, so... I won't fight someone downgrading this again, though
Comment #57
bas.hr CreditAttribution: bas.hr commentedComment #58
bas.hr CreditAttribution: bas.hr commentedPatch for D8
Comment #59
tstoecklerI'm marking this RTBC.
If we at some point decide to show no notice at all, we can always do that later. For now this is an improvement over the status quo, in that it shows them only once (on theme enable or install) and then never again. So let's get this in for now.
Comment #60
tstoecklerOops.
Comment #61
sunI wonder whether the proper behavior can be verified in a test. It appears to me that we could add two block definitions to block_test.module, one only pre-defining a non-existing 'region', the other additionally setting 'status' to 1, and assert the expected behavior on the block admin UI?
Comment #62
xjmActually, I am pretty sure bas_hr is currently working on a test for this. We looked at this issue during core mentoring yesterday.
Comment #63
bas.hr CreditAttribution: bas.hr commentedYes, as xjm said, I'm working on a test. I'm new in writing tests so it takes a while :)
@sun: I followed example from BlockHiddenRegionTestCase (block.test) and used block provided by the search modul to move it to the invalid region. Here is the test:
but I'm having trouble catching that drupal_set_message. Debug showed that block was disabled after drupal_flush_all_caches(). Any tips would be helpful. Tnx.
Comment #64
bas.hr CreditAttribution: bas.hr commentedHere is the proposed test case, I reused block from block_test.module
Comment #65
bas.hr CreditAttribution: bas.hr commentedMerged patch and test case
Comment #66
bas.hr CreditAttribution: bas.hr commentedSorry for being stupid, here it is one more time, merged patch and test case
Comment #67
tstoecklerActually the test should work without manually disabling the block. _block_rehash() (or similar) should do that for us. Otherwise the message still appears (potentially) at every cache clear, while the point of this issue is to prevent that.
Comment #68
bas.hr CreditAttribution: bas.hr commentedThat was a different test case, I've modified it a little bit to be more clear what is being tested.
Comment #69
tstoecklerThe test looks good.
I think this is almost ready to go.
The below looks like a lot, but it's really just nitpicks basically.
This is longer than 80 chars, but more importantly it is missing a couple articles (a/an) to be proper English. I would suggest something like:
"Tests that a block assigned to an invalid region triggers a warning."
(I think we can lose the "active", but that's debatable I guess.)
Should be "Blocks in invalid regions" (or alternatively, less preferred, though, I think: "Blocks in an invalid region"
"an non-existing" should be "a non-existing" (also if we go with "trigger" instaed of "issue" above, we should here, as well)
See above, more or less. :)
A/THE invalid region
More importantly: The last comment is followed by a code block which disables the block, even though we know it is already disabled. That looks strange to me.
This should be 'stark' not 'bartik'. (Yay!)
Minor, but the leading slash looks weird there IMO.
t() should not be used for the assertion message.
Trailing whitespace.
Also missing some articles.
Comment #70
NROTC_Webmaster CreditAttribution: NROTC_Webmaster commentedWhen you update this can you also upload the test only patch and the merged patch again so we can see the failure before and then pass after.
Comment #71
bas.hr CreditAttribution: bas.hr commentedtstoeckler thanks for the feedback, I'm attaching an updated patch. I hope now its OK :)
btw I saw all the assertion messages in the block.test are passed through the t(), should I open separate task for fixing that?
Comment #72
bas.hr CreditAttribution: bas.hr commentedHere is the test only patch
Comment #73
bas.hr CreditAttribution: bas.hr commentedComment #74
bas.hr CreditAttribution: bas.hr commentedRe-roll patch to apply cleanly to the latest 8.x as #135464: Add language options to block visibility has been committed.
Comment #75
tim.plunkettPart of me wishes this was
== TRUE
instead, but the status field is stored in the DB as a tinyint, 1 or 0. So that's fine.This looks good to me!
Comment #76
catchMe too. Committed/pushed to 8.x.
Comment #77
tim.plunkettSorry for stealing novice patches.
Comment #78
xjmFunny; before I clicked on this, I thought, "If that's Tim backporting ANOTHER one of the novice issues..." :)
Comment #79
webchickWow, great job on that test, bas.hr! Awesome work.
Committed and pushed to 7.x.
Comment #80
bas.hr CreditAttribution: bas.hr commentedThanks ;)
I think this needs backport to 6.x too.
Comment #81
NROTC_Webmaster CreditAttribution: NROTC_Webmaster commentedI'm not sure if it is necessary to check and see if $old_blocks[$module][$delta]['region'] != BLOCK_REGION_NONE or not but I didn't add that to this patch. If anyone thinks it should be just let me know.
Comment #82
ryan.gibson CreditAttribution: ryan.gibson commentedThe patch from #81 changed the block configuration but it didn't save the changes.
I'm still getting the message after hitting clear caches; it's not actually saving.
@timplunkett and I looked and saw that _block_rehash in D8 saves the block; in D6 this isn't happening.
Comment #83
xjmMarking NW based on #82.
Comment #84
mtiftI'm not a big fan of hacking core, but #8 worked for me as a temporary fix. I added something like this on line 285 of modules/block/block.module, just before the line that begins with "if (!empty($old_blocks)":
Comment #85
twinsdz CreditAttribution: twinsdz commented#40: warn_for_invalid_regions_only_for_active_blocks-1172560-40.patch queued for re-testing.
Comment #86
twinsdz CreditAttribution: twinsdz commented#71: warn_for_invalid_regions_only_for_active_blocks-1172560-70.patch queued for re-testing.
Comment #87
xatoo CreditAttribution: xatoo commentedWork is still needed as stated in #83, also, this is not a major issue.
Comment #88
drzraf CreditAttribution: drzraf commentedThis warning will happen when a theme changed its region naming.
Eg, from
sidebar_left
tosidebar_first
.What's the advised way to deal smoothly with such a change ?
Comment #89
maniosullivan CreditAttribution: maniosullivan commented#8 worked for me, and seems like the easiest soloution for anybody working with custom themes.
Comment #90
peterx CreditAttribution: peterx commentedSomething I found really easy was to add the name of the theme to the message then edit the list of blocks for the theme.
Comment #91
Pascal.s CreditAttribution: Pascal.s commentedI updated 6.22 to 6.28 and still had this problem. I tried creating a sidebar_left region in my .info file and still had the message showing. Since i'm working with a Zen subtheme, i tried adding the sidebar_left to the main zen.info file and it fixed my problem. So maybe it can help someone working with base themes and subthemes.
Comment #91.0
Pascal.s CreditAttribution: Pascal.s commentedAdded info about patch in #40 and explanation in #42.
Comment #92
fuzzy76 CreditAttribution: fuzzy76 commentedSo the default status of a block can only ever be 1 if you want you block in the 'content' region?