Title: PHP Warning: unserialize() expects parameter 1 to be string, array given
Last modified: May 10, 2021

---

# PHP Warning: unserialize() expects parameter 1 to be string, array given

 *  Resolved [erwinbr](https://wordpress.org/support/users/erwinbr/)
 * (@erwinbr)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/php-warning-unserialize-expects-parameter-1-to-be-string-array-given/)
 * 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](https://wordpress.org/support/users/erwinbr/)
 * (@erwinbr)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/php-warning-unserialize-expects-parameter-1-to-be-string-array-given/#post-14418935)
 * 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](https://wordpress.org/support/users/socialtech/)
 * (@socialtech)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/php-warning-unserialize-expects-parameter-1-to-be-string-array-given/#post-14419923)
 * Thank you for reporting this! We’ll investigate and update you.
 *  Plugin Contributor [socialtech](https://wordpress.org/support/users/socialtech/)
 * (@socialtech)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/php-warning-unserialize-expects-parameter-1-to-be-string-array-given/#post-14423864)
 * 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](https://tastewp.com)?
 *  Thread Starter [erwinbr](https://wordpress.org/support/users/erwinbr/)
 * (@erwinbr)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/php-warning-unserialize-expects-parameter-1-to-be-string-array-given/#post-14425646)
 * 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](https://wordpress.org/support/users/alexsev/)
 * (@alexsev)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/php-warning-unserialize-expects-parameter-1-to-be-string-array-given/#post-14536104)
 * The issue has been fixed. Could you please check?
 *  Thread Starter [erwinbr](https://wordpress.org/support/users/erwinbr/)
 * (@erwinbr)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/php-warning-unserialize-expects-parameter-1-to-be-string-array-given/#post-14542156)
 * 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.

 * ![](https://ps.w.org/ultimate-social-media-icons/assets/icon-128x128.gif?rev=
   2569754)
 * [Social Media Share Buttons & Social Sharing Icons](https://wordpress.org/plugins/ultimate-social-media-icons/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-social-media-icons/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-social-media-icons/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-social-media-icons/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-social-media-icons/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-social-media-icons/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [erwinbr](https://wordpress.org/support/users/erwinbr/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/php-warning-unserialize-expects-parameter-1-to-be-string-array-given/#post-14542156)
 * Status: resolved