WordPress.org

Support

Support » Plugins and Hacks » !get_option broken in WordPress 2.2?

!get_option broken in WordPress 2.2?

  • I have the following code in my plugin. Under WordPress 2.1.3 and previous it works correctly when the option is not in the options table:

    if (!get_option(“awsom_pixgallery_db_version”)) {
    add_option(“awsom_pixgallery_db_version”, $awsom_pixgallery_db_version);
    }

    Under WordPress 2.2 it is ignored and returns a true no matter if the option is there or not and creates a duplicate entry.

    I have confirmed this by doing 2 plain vanilla installs of the defaults for both versions and doing the exact same plugin install procedure.

    This appears to be a huge bug with the get_option function and may be leading to the cause of many plugins breaking in WordPress 2.2

    Is this being addressed? Will we see an update soon to fix this? I can rewrite the check to be the reverse, but that’s annoying and doesn’t address the issue.

Viewing 4 replies - 1 through 4 (of 4 total)
  • It looks like this has come up before: http://trac.wordpress.org/ticket/2268

    did it get broken again?

    If it is broken, then I’d open a new ticket at trac and refer back to that ticket 2268 as maybe the culprit.

    More information:
    the issue comes for me after following the plugin workflow listed in the codex for doing database updates:

    http://codex.wordpress.org/Creating_Tables_with_Plugins

    The query to get_option right after adding the option (if this is a new database install block) always fails even if the option is in the database (or the reverse, isn’t in the database)
    what happens is both the new install happens, then it runs through the upgrade area also. so the add_option in my case happens again.

    It looks like WordPress is caching the original query and not updating that an option was just added. Do we need a cache clear command for this? Is there one?

    More information: This only happens when add_option is used. update_option works fine. Since update_option works the same way as add_option I’ve switched my code to that.

    Just a FYI for all plugin developers, use update_option.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘!get_option broken in WordPress 2.2?’ is closed to new replies.