Fatal error in line 208

DesignWork - June 12, 2007 - 07:58
Project:User Read-Only
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:DesignWork
Status:closed
Description

Hi Mantainers,

I testet user read_only module in a client website and got a fatal cannot use string as an array error. The user wantet to change the contact settings in their account (this field was not user read_only protectet) but the array $form[$group][$key]['#attributes']['disabled'] = TRUE; could not be managed by drupal.

Quick and dirty solution is just to comment that line out (//). Problem you lose the hidden field, no gray in the backround any more. I will try to fix this, but any help is god because i´m to busy with more impotant stuff.

Dirk

#1

jaydub - August 14, 2007 - 08:53

I can't totally confirm this fix and I haven't been able to recreate the bug but what I did notice when testing is that the error occurs when the value for $group in the

foreach ($form as $group => $data) {

part of the code that surrounds the offending line 208 had a value of of '#name' where name
was something I can't recall. I wrapped the test in line 191 with a regex test to see if $group
matches the #xxxx name. So

if (!array_key_exists($key,$field_list)) {

becomes

if ( (!array_key_exists($key,$field_list)) || (preg_match("/^#/",$group)) ) {

#2

DesignWork - August 14, 2007 - 11:09

Hi jaydub,

i will test it today, thanks

Dirk

#3

JBrauer - August 15, 2007 - 23:59

I just ran into this today and made the change suggested by jdub in #1 and it worked well on our site.

#4

Junyor - January 11, 2008 - 20:24
Status:active» patch (code needs review)

This happens if the form has top-level stuff like #parameters and/or #attributes. Attached is a patch that fixes the issue. The fix is similar to the one suggested by jaydub, but the check was moved earlier to save some processing.

AttachmentSize
contrib-5.user_readonly.error_.junyor.patch681 bytes

#5

deekayen - June 13, 2008 - 19:03
Status:patch (code needs review)» fixed

committed

#6

Anonymous (not verified) - June 27, 2008 - 19:12
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.