子比主题将$comment传入获取头像的函数与 Redis-Object-Cache冲突

    • 苑晨岩
      楼主
      致命错误:未捕获的错误:类 WP_Comment 的对象无法在 /www/wwwroot/chenyan98.cn/wp-content/object-cache.php:2045 中转换为字符串堆栈跟踪:#0 /www/wwwroot/chenyan98.cn /wp-content/object-cache.php(2045): str_replace() 
      
      #1 /www/wwwroot/chenyan98.cn/wp-content/object-cache.php(2030): WP_Object_Cache->sanitize_key_part() 
      
      #2 / www/wwwroot/chenyan98.cn/wp-content/object-cache.php(1419): WP_Object_Cache->build_key() 
      
      #3 /www/wwwroot/chenyan98.cn/wp-content/object-cache.php(114) : WP_Object_Cache->get() 
      
      #4 /www/wwwroot/chenyan98.cn/wp-content/themes/zibll/inc/functions/zib-theme.php(349): wp_cache_get() 
      
      #5 /www/wwwroot/chenyan98 .cn/wp-content/themes/zibll/inc/functions/zib-comments-list.php(44): zib_get_data_avatar() 
      
      #6 /www/wwwroot/chenyan98.cn/wp-content/themes/zibll/inc/函数/zib-comments-list.php(18): zib_get_comments_list() 
      
      #7 /www/wwwroot/chenyan98.cn/wp-includes/class-walker-comment.php(179): zib_comments_list() 
      
      #8 /www/ wwwroot/chenyan98.cn/wp-includes/class-wp- walker.php(144): Walker_Comment->star in /www/wwwroot/chenyan98.cn/wp-content/object-cache.php on line 2045

      以上是翻译过的报错信息,已分行。

  • 孙锡源
    管理员

    WordPress的头像获取函数默认是传递用户id或邮箱地址的,所以也建议传递用户id或邮箱,而不是将评论对象整个传过去。

    这个报错的意思是评论对象无法被WordPress的缓存相关帮助函数用作键值。如果确定必须传递评论对象的话可以把自定义的获取头像的函数中带wp_cache相关的行都删掉。

  • 正在查看 1 条回复
    • 哎呀,回复话题必需登录。

    加入 LitePress 论坛 ,参与知识分享与交流
    登录 注册 进行评论
    立即加入