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.

Comments

damien tournoud’s picture

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:

$form['title'] = "toto";

instead of

$form['#title'] = "toto";
tic2000’s picture

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

tic2000’s picture

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.

damien tournoud’s picture

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.

damien tournoud’s picture

Issue tags: -Quick fix
tic2000’s picture

Title: E_NOTICE thrown by element_child() » E_NOTICE thrown by element_child() on user/%uid/edit page
Status: Needs work » Needs review
StatusFileSize
new2.29 KB

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

Status: Needs review » Needs work

The last submitted patch failed testing.

tic2000’s picture

Status: Needs work » Needs review
StatusFileSize
new2.32 KB

Lets see if this one passes.

damien tournoud’s picture

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.

tic2000’s picture

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.

tic2000’s picture

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 :)

Status: Needs review » Needs work

The last submitted patch failed testing.

deekayen’s picture

Status: Needs work » Needs review

core was broken

aaronbauman’s picture

Status: Needs review » Closed (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

aaronbauman’s picture

Status: Closed (won't fix) » Closed (fixed)