Skip to content

Redis Cache - Deprecated: unserialize(): Passing null to parameter #1. #4497

@alexius

Description

@alexius

Hello everybody,
after updating Yii 1 to the version 1.1.27 we got this error:

Deprecated: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in /srv/www/htdocs/ilya/mike.matthies.p2/protected/framework/caching/CCache.php on line 108

What steps will reproduce the problem?

We use cache during SQL request:

$query = Yii::app()->db->cache(3600) ->createCommand() ->select('*, id') ->from('table') ->where('cond=1'); $rows = $query->queryAll();

The function
CDbCommand->queryAll( $fetchAssociative = ???, $params = ??? )
uses another function
CDbCommand->queryInternal( $method = 'fetchAll', $mode = [0 => 2], $params = [] ), which uses the function
CCache->get( ...). There is a code in function CCache->get( ...):

if($this->serializer===null) $value=unserialize($value);

which should be adjust. Passing null as a value to the function 'unserialize()' is deprecated now.

What is the expected result?

If null, the function should just return value as for the case when we have false.

What do you get instead?

We get error 'Deprecated'.

Additional info

Q A
Yii version 1.1.27
PHP version 8.1.2
Operating system Ubuntu 22.04.1 LTS

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions