Closed (outdated)
Project:
Drupal core
Version:
6.x-dev
Component:
block.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
12 Jul 2012 at 07:21 UTC
Updated:
2 Mar 2016 at 22:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
vigneshbabu commentedHi,
Any idea on why this was happening?
Thanks in advance
-Vignesh
Comment #2
GDI commentedHave the same issue with Drupal 6.25.
I think this issue caused by PHP 5.4
Comment #3
Gulzar commentedsee the warning goto mentioned line and remove "&"
thanks
Comment #4
raymacz commentedI have exactly the same issues as this one.. Hoping we have a fix soon... Thanks!
Comment #5
mdupontThis is caused by PHP 5.4 that raises warnings for some behaviors that were valid with previous versions of PHP. Drupal 6 does not support PHP 5.4 and likely never will since EOL is not far away.
Comment #6
NaX commentedI think I found the problem. I changed block_admin_display_form_submit() to check for an array():
The problem seems to be that block_admin_display_form_submit() handler is just looping through all the form values assuming each value is a valid block settings form array() and when it hits fields relating to the buttons and form ID then it errors because it is not an array.
I dont know if its nessary but the more correct way could be to loop through blocks.
Hope it helps
Comment #7
RStrydom commented#6 Patch works for me
I have re-rolled the patch, built against 6.28
Comment #8
RStrydom commentedApologies.
attached re-rolled with correct syntax
Comment #9
NaX commentedComment #10
ibnkhaldun commentedI have the same issue on Drupal 6.28 !
I'll test your fix, just now ...
Why does the issue exists when there is a patch ?
Comment #11
ridavao commentedthe patch works perfect! thanks drupal community!
Comment #12
NaX commentedChanging issue title back
Comment #13
pfaocleThanks for this, just applied it & seems to fix the issue. (Some trailing whitespace has been added in the patch though.)
Comment #14
TJ commented#8: block.admin_.inc_.patch queued for re-testing.
Comment #15
ibnkhaldun commentedThe problem re-apears on Drupal 6.29
I've updated a test site from D6.28 to D6.29 two days ago. So replaced the block module.
I remember this issue, went to bloks list and moved 1. Surprice...
warning: Illegal string offset 'region' in /home/user/lampstack-5.4.11-0/apache2/htdocs/herramientasd6/modules/block/block.admin.inc on line 101.
warning: Illegal string offset 'status' in /home/user/lampstack-5.4.11-0/apache2/htdocs/herramientasd6/modules/block/block.admin.inc on line 101.
warning: Illegal string offset 'status' in /home/user/lampstack-5.4.11-0/apache2/htdocs/herramientasd6/modules/block/block.admin.inc on line 102. at least 30 warning rows. I'll retest the patch idea over 6.29
As I was almost sure the propoused patch is misdirected. I perform a test to read the $form_state['values'] content because NOT ALL of it's elements are block definitions. It means there are several cases where $block[$key] is undefined so raises errors.
And as you can see: the last 5 elements aren't arrays so aren't block definitions. Thus you got error when iterate over them.
I conclude:
The patch must test if gets or not an array So, pls return to first option at comment #6
Comment #16
NaX commented@ibnkhaldun
I don't think just checking if it is an array is very safe or secure. I think the patch #8 is best because it only uses defined blocks. Maybe we can combine the two and check if the key exists in the array before updating. But if the block key does not exist that is an error and should not be suppressed or worked around. If the key does not exist and we prevent the warning then we should at least log to watchdog the error, because the error could point to problems higher up the submission stack.
Just my 2 cents.
Comment #17
ibnkhaldun commented@NaX
As i can see, the loop over $form_state['values'] is the main why to retrive submited values. So $blocks = _block_rehash(); is an unnecesary extra proccess. We only need to exclude 5 keys. Other are blocks. So adding a conditional to exclude is safe.
A second way is to exclude using explicit keys:
Comment #18
NaX commented@ibnkhaldun
Here is a scenario for you, let me now what you think.
You have two admin's both working on blocks. One deletes a block the other re-orders the blocks. The second admin loads the page before the first admin deletes the block, but submits the re-order update after the block is deleted. With the array method the user will get a SQL error trying to update a record that does not exist. With the Block rehash method only blocks will be updated that exist in the system at that time and form values that are no-longer relevant will be ignored. Maintain referential integrity, security and not scaring the user will irrelevant error messages.
What do you think? Do you think this scenario is relevant?
Comment #19
ibnkhaldun commentedCompletely on agree.
Then wath about if 1 admin deletes a block while the 2nd updates it?
It's the same scenario 2 admins working, each one his own row ... a extrange site but possible
Comment #21
Jamie Holly commentedIMHO this issue should pertain just to the warning, since that can quickly add up to a bunch of writes to the dblog and/or error logs. To suppress that, the is_array method works great. As far as the scenario of two admins doing block work at the same time, I can easily see that happening, but that should honestly be made into a separate issue.
Comment #22
mw4ll4c3 commentedHere's a clean, freshly rolled patch for the scalar key warnings. Just an is_array() one-liner, no _rehash().
100% with Jamie; anything more should be its own issue, if anyone is inspired. I agree the oversight here could have once lead to unexpected behavior, but that behavior was established long ago. Anyone doing anything "interesting" with the form either added their own submitter to the chain, or found a better home for their changes, long ago.
Comment #23
ibnkhaldun commentedComment #24
ibnkhaldun commentedI think the patch on #22 is good enough. It's clean and does not run expensive reloads.
Comment #25
jonathan1055 commentedPatch in #22 is more approriate for this issue. I agree - RTBC
Comment #26
xaa commented#22 working. thank you. (with drupal6.33)
Comment #27
JamesK commented#22 still is fine on 6.34
Comment #28
ibnkhaldun commentedI'd changed the status to be reported. I think It is good enough!
Comment #29
jonathan1055 commentedHi, I think you mis-understand 'Patch to be ported' means it has been committed to one branch of code and needs to be ported to another branch too. This change has not been committed yet, so it needs to stay as RTBC
Comment #30
ibnkhaldun commentedOh! sorry i'll return to previous stage!
Comment #31
mw4ll4c3 commentedThank you all for keeping up on this!
Since you guys are working in similar environments, you should know I have a few similar fixes for some common mods that you may need (they could probably stand some expansion, a reroll, or just an RTBC)