Background of the issue:
I am trying to resolve an error related to Redis that appears frequently in my server logs. The error occurs on the route /wp-json/wpml/tm/v1/ate/jobs/download, which is controlled by WPML. The error message is: Error at /var/www/html/web/app/object-cache.php at line 2668 'Trying to clone an uncloneable object of class Redis'. The solution involves modifying the __clone() method of the class containing the Redis object to either recreate a new Redis connection or set the Redis property to null during cloning. Here is the code snippet I am considering: ```php public function __clone() { if (isset($this->redis) && $this->redis instanceof Redis) { $this->redis = new Redis(); if ($this->connected) { $this->redis->connect($this->server, $this->port, $this->timeout); if (!empty($this->password)) { $this->redis->auth($this->password); } if (isset($this->database)) { $this->redis->select($this->database); } } } } ```
Symptoms:
I am encountering a 500 error due to a 'Trying to clone an uncloneable object of class Redis' message in the server logs.
Since it's related to WPML and to the Redis Cache plugin, I've also shared the bug to their github repository: hidden link Feel free to discuss it there if you prefer.
Questions:
How can I prevent the 'Trying to clone an uncloneable object of class Redis' error?
Here is the ticket—let’s continue the discussion here.
1) Are there any specific steps that consistently trigger the issue, such as re-translating certain content or performing another particular action?
2) Since you have already reported this to the Redis team and the fix involves modifying their code, let’s wait for their feedback. They will likely have more insight into why this is happening, what may be causing it, and whether it could be related to anything on the WPML side.