WordPress.org

Ready to get started?Download WordPress

Forums

2.5 problems: Fatal error with string offsets in widgets.php on line 340 (15 posts)

  1. Shantaram
    Member
    Posted 6 years ago #

    I recently updated my version of WordPress from 2.3 to 2.5. The first thing that happened was that K2, the theme I'm using, conflicted with the new widgetized dashboard of WP 2.5. I got the
    Call to undefined function wp_register_sidebar_widget() in */wp-admin/includes/dashboard.php at line 31
    error that was solved here, but before I tried that I had already gone and changed the folder name of the K2 theme to try and force WordPress to use the default theme.

    After the folder name change, and now it doesn't matter if I change it back, I get this error:
    Fatal error: Cannot unset string offsets in */wp-includes/widgets.php on line 340

    I have no idea why, but apparently it's something about widgets. A quick check in the widgets.php in question, line 340 prints:
    unset($sidebars_widgets['array_version']);

    And here is where I don't know where to look further. I can't access any of the WordPress files without getting the fatal error above. Does anyone know what is causing this problem? I tried searching for it but couldn't find anyone else with the same problem.

  2. hakre
    Member
    Posted 6 years ago #

    Looks like an unintialized array key/value pair. Have you tried to install a blank wordpress 2.5 and does this error occur as well there? I know quite the hard way but just asking.

    Another Idea I have got is that the widget management went gagga. Anyway to reset that? Are you familiar with wordpress database / phpmyadmin maybe?

  3. Shantaram
    Member
    Posted 6 years ago #

    I do know how to work my way around phpmyadmin, but I have no clue what to look for. Since the database now is upgraded (and I don't have an especially new backup *crouches for thrown stuff flying my way*) I'll just have to solve it as it is. Will try to delete all the wordpress files later on when I'm on a stable and fast connection and upload them again.

  4. hakre
    Member
    Posted 6 years ago #

    Check you're using the latest file.

    // for the sake of PHP warnings
    if ( empty( $sidebars_widgets[$sidebar] ) )
    	$sidebars_widgets[$sidebar] = array();

    line 45ff in wp-admin/widgets.php

    this should prevent your error. If you still get it and you are very shure you have got the latest file, then please create a MD5 checksum of your wp-admin/widgets.php, and post where you donwloaded the wordpress archiv (link please to zip / tar.gz) then this should be solveable.

  5. Shantaram
    Member
    Posted 6 years ago #

    What do you mean by line 45ff?

  6. hakre
    Member
    Posted 6 years ago #

    ff = following (ff in anorak 2.0).

  7. Shantaram
    Member
    Posted 6 years ago #

    All right, I have tried uploading and replacing all of the 2.5 files again to no avail. Naturally, the 2.5 files were downloaded from here; wordpress.org (link). Created a MD5 checksum of my wp-admin/widgets.php here:

    97e729f2a6a325148d6e9311fa5d33be

    And here's one from my wp-includes/widgets.php as well, just in case:

    a420a1978437032f7e5d0131585e06a5

    Anything else I can do? I tried deleting plugins and deleting themes, but nothing happens. Whatever file I try to access in my WordPress directory on the host gives me

    Fatal error: Cannot unset string offsets in */wp-includes/widgets.php on line 340

    Sigh.

  8. Shantaram
    Member
    Posted 6 years ago #

    So I've downloaded 2.5 again as both .zip and .tar-gz from wordpress.org and checked the MD5's of all the widgets.php files I have, and they're all identical. Total confusion!

    How would I go about to reset the widget management through phpmyadmin?

    I've seen several other posts on the forum without answers about the widgets.php files causing fatal errors. No developer that's got a clue why this is happening...?

  9. Shantaram
    Member
    Posted 6 years ago #

    Sorry for spamming posts now, but I thought I'd just update the thread as I go along so that anyone else who might sometime encounter the same problem can solve it. I edited some stuff in my wp-config.php, and if I change $table_prefix = 'wp_'; to $table_prefix = ''; it does indeed make the blog work in with 2.5. Since "wp_" is apparently the prefix I'm using for my blog, when I change back I get the error again.

    But clearly, somethings f'd up in the database. Next step? Thank you for your time in this, hakre.

  10. hakre
    Member
    Posted 6 years ago #

    Okay, this is one step ahead. So this Error is triggered because of some data coming out of the database.

    I guess this is from the table wp_options, maybe some widget options are faulty? most of their option_name contain a string starting with widget_.

    The whole config is stored in sidebars_widgets.

    NOTE: Make a Backup of your MySQL data (just another one after upgrade to be on the safe side).

    Reset Widget Settings
    SQL-Query to reset widget sidebar configuration:
    UPDATE wp_options SET option_name = CONCAT('debugbak_', option_name) WHERE option_name = 'sidebars_widgets';

    This might fix your problem, just test. It's a guess. If not please try this one that will disable all widget configurations:

    UPDATE wp_options SET option_name = CONCAT('debugbak_', option_name) WHERE option_name LIKE ('widget_%');

    This should remove only the widgets configuration. If this already helps then we pinned it down to one of those values. If not, both SQL Queries are undo-able by running a counterpart SQL query:

    UPDATE wp_options SET option_name = SUBSTR(option_name, 10) WHERE option_name LIKE ('debugbak_%');

    (tested both queries on a testsystem running MySQL - 5.0.19-nt)

    Hopefully this helps, if not we gathered at least some more infos. Please test.

  11. hakre
    Member
    Posted 6 years ago #

    I found some more stuff, please take a look in this thread, maybe this is the quite of a same problem: [resolved] 2.5 - Fatal Error: Cannot use string offset as an array, line 46 dashboard.php

    They got it fixed with with an option called dashboard_widget_options - but that was for the dashboard ;)

  12. Shantaram
    Member
    Posted 6 years ago #

    All right mate, I did as you said and the first option got me rid of the error. When I load up the blog, everything has changed charset from UTF-8 (I think this doesn't have anything to do with my previous problem though, AFAIK WordPress usually likes to mess charsets up in the upgrades), and every blog post gets a 404 error (or rather, directs to the root of my domain which is what the host set it to do in case of 404) when I click on the title.

    You can see the result here. But since the dashboard and blog in general seems to be working at least better than before, I'd try to find answers to the new errors in forums. As long as there's nothing more to do about the widgets thing?

    Thanks a lot man, I never would've figured this out.

  13. hakre
    Member
    Posted 6 years ago #

    Nice, to hear that this solved your problem. With your charset problem, I'd like to get more infos about what you experienced. Your site right now looks quite fixed. Maybe you can start a new thread for this and reference it here?

  14. ealodder
    Member
    Posted 6 years ago #

    Note for all others who have the same problem.

    The solution is quit simple. After a upgrade to at least 2.5 the file widgets.php has a problem with the charset.

    The Charset is a new option in the wp-config.php file (In the root folder) Standard is this setting define('DB_CHARSET', 'utf8'); just remove the utf8 and the problem is solved.

  15. milou16
    Member
    Posted 5 years ago #

    Ealodder, it's not working for me I'm affraid. I'm using 2.6.2, and there you have that utf8 but I removed and nothing changed:(. I have the same problem....

    Fatal error: Cannot unset string offsets in /home/flypink.nl/www/wordpress/wp-includes/widgets.php on line 362

Topic Closed

This topic has been closed to new replies.

About this Topic