Closed prakash-bbsr closed 2 years ago
Hello,
The method JsonSerializable::jsonSerialize
is implemented in \Phpfastcache\Core\Item\ItemExtendedTrait::jsonSerialize
.
So you either have an Opcache issue on your PHP installation, or an issue with your composer install, but this issue is definitely on your side.
Especially since the latest build on V7 passed successfully: https://app.travis-ci.com/github/PHPSocialNetwork/phpfastcache/builds/250964552
Hi Geolim4, Thanks for your reply. We are not able to reproduce this issue in lower environment. This issue is randomly occuring on the production server. If we reproduce this issue in lower environment then we can easily debug. I am suspecting this is not related to the installation of php version or composer. Could you please help in which scenarios we can generate the above type of issue.Once we got the root cause of the problem then we can easily find the solution
It's simply impossible to reproduce this issue because it looks like a lexer issue of PHP.
My guess is that you should upgrade your PHP installation which is very old now. 7.0.33 has been released in december 2018.
Also PHP 7.1 fixed some bugs related to JsonSerializable interface:
I'm highly suggesting you to migrate at least to PHP 7.3 or even better 7.4 if you can.
Hi Geolim, Thanks for your suggestion. As dependent of other libraries we can't change the current version of PHP on server. Could you please help how can we generate exception in lower environment. May be this type of exception because of high traffic but not sure. We have observed this exception is occurring at night owing to this suspecting high traffic. This exception not occurring frequently. This exception is occurring 2-3 days interval.
Hi Geolim4, I have checked there are multiple libraries in our code base. I found most of the libraries have JsonSerialized but not getting any issue in that libraries. I am suspecting this error because of the below reason. vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Core/Item/ExtendedCacheItemInterface.php inherits from \JsonSerializable but not overwrite the the method jsonSerialize() .
Hi Geolim4, I am able to reproduce that type of error. In the below example BinaryValue inherits from JsonSerializable but not define the method jsonSerialize() then we can get such type of error. [Fri Jun 10 12:18:03.838127 2022] [php:error] [pid 15258] [client ::1:47110] PHP Fatal error: Class BinaryValue contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize) in /var/www/html/test/fastcache.php on line 2
In my previous mail i had raised the same vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Core/Item/ExtendedCacheItemInterface.php inherits from \JsonSerializable
Need to define the method jsonSerialize() in this vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Core/Item/ExtendedCacheItemInterface.php
<?php class BinaryValue implements \JsonSerializable { public $value; public function __construct($value){ $this->value = (string) $value; } public function jsonSerialize(){ //return $this->value; } public function test(){ return $this->value; } } $obj= new BinaryValue(60); echo $obj->value; ?> Could you please add your suggestion.
No it's not a Phpfastcache issue as I already said above.
The method JsonSerializable::jsonSerialize
is implemented in \Phpfastcache\Core\Item\ItemExtendedTrait::jsonSerialize
.
And the class Phpfastcache\Drivers\Files\Item
use that trait that implement the method jsonSerialize
.
If it was Phpfastcache's fault none of the CI would have passed and many people would have reported this issue, especially the v7 has been released since 3 years now.
So I strongly suggest you to upgrade your PHP version which is no longer supported since a long time now.
Something is wrong with your PHP binary and it's not Phpfastcache fault, sorry 🤷🏻
This exception is occurring 2-3 days interval.
This clearly not related to Phpfastcache. If it was a compile error (which the error is all about) you would reproduce the error at each requests, immediately.
You either have an I/O issue due to a high traffic (and PHP is unable to open & compile PHP scripts in time) or your PHP binary is having some issues, which is pretty possible since it's getting very old now and 7.1 have already fixed JsonSerialize related errors.
Hello @prakashmuvi ,
I’m closing this issue for now because of (inactivity / outdated code / …).
You can always reopen it though! :) Please (update the issue / add comment / clarify …).
Regards, Georges.L
Configuration
Describe the bug
We have got this exception. Sometimes server is down but not sure server was down because of this issue
To Reproduce Steps to reproduce the behavior: