cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[BUG]: phalcon/Storage/Serializer/Json.zep can't serialize stdClass

Open pwtitle opened this issue 6 months ago • 0 comments

phalcon/Storage/Serializer/Json.zep can't serialize stdClass

        $serializerFactory = new \Phalcon\Storage\SerializerFactory();
        $adapterFactory    = new \Phalcon\Cache\AdapterFactory($serializerFactory);

        $adapter = $adapterFactory->newInstance('redis', [
            'defaultSerializer' => 'Json',
            "host"              => "***",
            'lifetime'          => 7200,
            "auth"              => "****",
        ]);
        $cache = new \Phalcon\Cache\Cache($adapter);

        $who = new \stdClass();
        $who->name = "testName";

        $cache->set("test", $who);  // this line get error: Data for the JSON serializer cannot be of type 'object' without implementing 'JsonSerializable'

Screenshots 123

Details

  • Phalcon version: 5.8.0
  • PHP Version: 8.3.9

pwtitle avatar Jul 28 '24 08:07 pwtitle