• Resolved erwinbr

    (@erwinbr)


    The php log shows countless warnings from your plugin like:

    PHP Warning: unserialize() expects parameter 1 to be string, array given in ultimate_social_media_icons.php on line 114.

    Your code contains about 200 occurrences of this code pattern:
    unserialize(get_option(...))
    while the WP function get_option() already calls maybe_unserialize(). So unserialize() should not be called on results of get_option().

    If for some reason you stil expect to get serialized data, use maybe_unserialize(), but I could not find any pattern of that in any code of other plugins or in core itself in my current project.

    So, it would be nice if you could correct this in your next version.

    Thanks,
    Erwin Derksen | Buro RaDer

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter erwinbr

    (@erwinbr)

    Oh, I now see that unserialize() returns false if the passed string cannot be unserialized (instead of just returning the value). This means that this is now a real error and no longer a warning: all option values are changed into false and thus settings being ignored with lots of

    Trying to access array offset on value of type bool

    notices.

    Plugin Contributor socialtech

    (@socialtech)

    Thank you for reporting this! We’ll investigate and update you.

    Plugin Contributor socialtech

    (@socialtech)

    We have checked our plugin and we can’t replicate the same error or any notice in the server log as you indicate so can you please send us steps to replicate the issue? Also please share details of your PHP version, WP version, etc.

    Or, to make it even easier, could you please see if you can replicate it by spinning a WordPress site with https://tastewp.com?

    Thread Starter erwinbr

    (@erwinbr)

    Thanks for your response,

    I did some further digging and found that it only occurs if I use a persistent object cache (or more specifically, I am using Docket Cache as I am working on a site whose hoster does not offer memcached, apcu or Redis). Apparently, the values of the options as stored in the cache get unserialized while still being linked/referenced to the cache or are stored before being serialized or something like that.

    However, it also looks like your plugin doubly serializes its options (in the plugin itself and in add/update_option()) which seems unnecessary as well. So I think that changing unserialize() to maybe_unserialize() solves the problem. (You could then even remove the calls to serialize() in your own code and not have to write an db update function.)

    I hope this helps,

    Plugin Support alexsev

    (@alexsev)

    The issue has been fixed. Could you please check?

    Thread Starter erwinbr

    (@erwinbr)

    I updated your plugin and the notices are gone. Thanks a lot!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP Warning: unserialize() expects parameter 1 to be string, array given’ is closed to new replies.