E_NOTICE thrown by element_children() on user/%uid/edit page

tic2000 - July 12, 2009 - 17:57
Project:Drupal
Version:7.x-dev
Component:base system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

When I go to user edit page I see

* Notice: Uninitialized string offset: 0 in element_children() (line 4045 of /home/tic2000/public_html/d7/includes/common.inc).
* Notice: Uninitialized string offset: 0 in element_children() (line 4045 of /home/tic2000/public_html/d7/includes/common.inc).

The patch solves the problem.

AttachmentSizeStatusTest resultOperations
user-edit-remove-notice.patch771 bytesIdleFailed: 11168 passes, 663 fails, 585 exceptionsView details

#1

Damien Tournoud - July 12, 2009 - 18:02
Status:needs review» needs work

More precisely, this patch *hides* the problem. Please find why element_children() is bumping into a string where it should find an array. That's probably due to something like this:

<?php
$form
['title'] = "toto";
?>

instead of

<?php
$form
['#title'] = "toto";
?>

#2

tic2000 - July 12, 2009 - 19:44

No. In that case $key[0] would be 't' and no notice would be thrown.

#3

tic2000 - July 12, 2009 - 20:28

The problem comes from this

        // For the default theme, revert to an empty string so the user's theme updates when the site theme is changed.
        $info->key = $info->name == variable_get('theme_default', 'garland') ? '' : $info->name;

in system_theme_select_form().

And now that I look at that code I see an usability problem too. A user can't select a default theme to be his default theme. If the site's default theme changes his theme changes too, even if he actually selected a certain theme (which happen to be the default theme of the site at that time).

Now, do we solve the initial problem? I know drupal doesn't babysits broken code, but I don't know if using an array with an empty key qualifies as broken code.

For the usability problem, I think that theme selection form on user edit page should have an option "Use default theme" which should use 'use_default_theme' as $key to avoid the Notice message.

#4

Damien Tournoud - July 12, 2009 - 20:41

The empty string is not really a valid key. If you do want to hide that under the carpet, you would at least need to use strlen($key) > 0.

I believe we still need to fix the root issue.

#5

Damien Tournoud - July 12, 2009 - 20:41

#6

tic2000 - July 13, 2009 - 05:48
Title:E_NOTICE thrown by element_child()» E_NOTICE thrown by element_child() on user/%uid/edit page
Status:needs work» needs review

This patch treats the root of problem instead of just making it shut up.

AttachmentSizeStatusTest resultOperations
user-edit-remove-notice.patch2.29 KBIdleFailed: 11631 passes, 33 fails, 1558 exceptionsView details

#7

System Message - July 13, 2009 - 05:57
Status:needs review» needs work

The last submitted patch failed testing.

#8

tic2000 - July 13, 2009 - 10:37
Status:needs work» needs review

Lets see if this one passes.

AttachmentSizeStatusTest resultOperations
user-edit-remove-notice.patch2.32 KBIdleFailed: 11908 passes, 3 fails, 0 exceptionsView details

#9

Damien Tournoud - July 13, 2009 - 10:40

I'm not sure I understand this one right, why does an empty string key in a #options (which is perfectly valid) causes notices in element_children()? This sounds weird.

#10

tic2000 - July 13, 2009 - 10:52

Because element_child() does an foreach $key => $value and inside that does a $key[0] which should get the first character of the string, but if there is no string in throws a Notice.

Why is element_child() called on that is above my expertise right now.

Edit: I opened #517662: Can't select site's default theme as user's theme for the usability problem.

#11

tic2000 - July 13, 2009 - 11:09
Title:E_NOTICE thrown by element_child() on user/%uid/edit page» E_NOTICE thrown by element_children() on user/%uid/edit page

Fix to the title :)

#12

System Message - July 30, 2009 - 20:36
Status:needs review» needs work

The last submitted patch failed testing.

#13

deekayen - July 30, 2009 - 20:55
Status:needs work» needs review

core was broken

#14

aaronbauman - November 9, 2009 - 18:19
Status:needs review» won't fix

per-user configurable themes removed from core.
renders this issue moot.
see #292253: Remove the per-user themes selection from core and http://drupal.org/node/517662#comment-1900532

#15

aaronbauman - November 9, 2009 - 18:20
Status:won't fix» closed
 
 

Drupal is a registered trademark of Dries Buytaert.