• Resolved Mat

    (@matdabrowski)


    Hi, I have a problem with one of the plugins. With Docket Cache enabled, i got error:

    Fatal error: Uncaught TypeError: unserialize(): Argument #1 ($data) must be of type string, OauthResultClientCredentials given in /path/to/file/wp-content/plugins/woo-payu-payment-gateway/Payu/Cache/OauthCache.php:10

    A here is this part of file OauthCache.php:

    public function get( $key ) {
    $cache = get_transient( $key ); // line 8

    return $cache === false ? null : unserialize( $cache ); // line 10
    }

    With Docket Cache enabled, in line 8 get_transient( $key ); returns object OauthResultClientCredentials, so in $cache variable we have this object, but in line 10, string is expected (in $cache) as input for unserialize(…) method.
    Without Docket Cache, everything is ok, because in database string is stored for this key (serialized object stored as string).

    So, I think get_transient() should return string in both case.

    I can fix it with setup:
    Retain Transients in Db: Enable – but what does it mean? Does it mean that transients are not optimized?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Nawawi Jamili

    (@nawawijamili)

    Hi there,

    The unserialize function should be replaced with maybe_unserialize, this should fix the code.

    public function get( $key ) {
    $cache = get_transient( $key ); // line 8

    return $cache === false ? null : maybe_unserialize( $cache ); // line 10
    }

    Retain Transients in Db: Enable – but what does it mean? Does it mean that transients are not optimized?

    This means that Docket Cache will not cache the transient data. It will leave it as is.

    This option is to avoid such cases because we can’t ask all plugin authors to change the use of unserialize to maybe_unserialize. And sometimes transients are misused and contain a lot of data that Docket Cache can’t handle. Handing it over to the database is the solutions we have.

    Thanks.

    Thread Starter Mat

    (@matdabrowski)

    Thank you for your answer. I understand that. I’ll try to reach plugin developers, or mayby I’ll fix this by myself.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Fatal error: Uncaught TypeError: unserialize(): Argument #1 ($data)’ is closed to new replies.