#6532 closed defect (bug) (duplicate)
db collation and db charset break serialize and unserialize on some sites
Reported by: | tandilboy | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.5 |
Component: | General | Keywords: | dev-feedback |
Focuses: | Cc: |
Description
shows this error
Warning: array_keys() [function.array-keys]: The first argument should be an array in /www/lu22radiotandil.com.ar/htdocs/wp-includes/widgets.php on line 654
Warning: Invalid argument supplied for foreach() in /www/lu22radiotandil.com.ar/htdocs/wp-includes/widgets.php on line 654
i Using PHP 5 + MySQL 5.0
my blog
http://www.lu22radiotandil.com.ar (fix the error please). send the fix
Attachments (1)
Change History (15)
#2
@
16 years ago
i apply the fix but the error dont fix
Warning: array_keys() [function.array-keys]: The first argument should be an array in /www/lu22radiotandil.com.ar/htdocs/wp-includes/widgets.php on line 654
Warning: Invalid argument supplied for foreach() in /www/lu22radiotandil.com.ar/htdocs/wp-includes/widgets.php on line 654
check at
http://www.lu22radiotandil.com.ar
PLEASE FIX :(
#3
@
16 years ago
DD32, it's nice to see you try to patch something but on the otherhand please only patch something if you analyzed the actual bug and found its cause. Otherwise this can result in one or many steps backwards.
tandilboy, please setup a brandnew 2.5 installation from scratch and report if this error still occurs. then copy over, one by one, the plugins that do have your widgets and test them one after another when the error occurs.
Since widgets API changed (as far as I can see), it might be the case that one or more of your widgets does not work with 2.5.
#4
@
16 years ago
NOTE: the error shows in all Admin pages too.
No solution deactivating all plugins and reinstalling wordpress
#5
@
16 years ago
Just a guess... in your theme, insert this code somewhere to see the output:
var_dump(get_option('widget_text'));
if this outputs a weird looking string with braces and semicolons all over, instead of a nice array, this means your option's value is corrupt.
assuming so... I've seen this happen a bunch of time on my own customers' blogs, not to mention my own.
open phpmyadmin, and run:
delete from wp_options where option_name = 'widget_text';
this will delete the text widgets and let you recreate them as appropriate.
while fixing customer sites, I've found that the true underlying issue was that, for some reason, WP's db charset and db collation settings that do not play well with serialize and unserialize.
this brings me to the second fix in the event it reoccurs later on. edit the wp-config.php file, and to remove the two defines for db charsets and db collation. then, delete the widget text option again, and you should be fine in the future.
anyway, if the above tip fixes your site, change this ticket's title to:
db collation and db charset break serialize and unserialize on some sites
also provide sample text and the original db collation and charset settings, and the contents of your phpinfo so the devs can try to reproduce. it would be nice if it no longer occurred. :)
D.
#6
@
16 years ago
- Resolution set to fixed
- Status changed from new to closed
Denis-de-Bernardy
the fix works well :D
i deleted the widget_text from wp_options. and the error fixed :)
thank u :)
#7
@
16 years ago
- Milestone changed from 2.5.1 to 2.6
- Priority changed from high to normal
- Resolution fixed deleted
- Severity changed from major to normal
- Status changed from closed to reopened
- Summary changed from Warning: The first argument should be an array in /www/lu22radiotandil.com.ar/htdocs/wp-includes/widgets.php on line 654 to db collation and db charset break serialize and unserialize on some sites
#8
@
16 years ago
might be the fix:
http://fr3.php.net/manual/en/function.unserialize.php#76012
#9
@
16 years ago
other candidate:
http://fr3.php.net/manual/en/function.unserialize.php#73296
#10
@
16 years ago
Nazgul are you shure this is charset related? If then, isn't it a configuration issue?
#11
@
16 years ago
- Keywords dev-feedback added
No no, it's charset-related all right. I've seen this happen often enough to know, and I ran into the "real" issue while investigating this in a separate app.
unserialize() uses strlen() to determine the length of strings, and strlen() occasionally outputs erroneous string lengths when using multibyte characters. Trying to overload strlen() using the ini setup is hopeless to make it mb safe, because unserialize() will still use, internally, the non-mb safe version of strlen().
If my memory serves me well the php devs have no intention to fix it. So I resolved (in the other app) to never serialize anything that may contain captions or user-editable text.
This means that fixing the text widget (and all sorts of other plugins, widgets, meta options, etc.) would mean introducing separate options to store user-editable text, rather than storing them within an array.
Should fix it. I couldnt reproduce the error though, The only way i can see it could happen is if widget_text contained a non-array value, which shouldnt actually happen AFAIK?