当前位置: 首页 > news >正文

colinmollenhour/credis 1.17 bug

Call to a member function getMode() on nullvendor\colinmollenhour\credis\Client.php(783): Credis_Client->assertNotPipelineOrMulti('Credis_Client::...')

错误代码

#Credis_Client vendor\colinmollenhour\credis\Client.php/*** @param ?int $Iterator* @param string $pattern* @param int $count* @return bool|array* @throws CredisException*/public function scan(&$Iterator, $pattern = null, $count = null) {$this->assertNotPipelineOrMulti(__METHOD__);return $this->__call('scan', array(&$Iterator, $pattern, $count));}/*** @param string $caller* @return void* @throws CredisException*/protected function assertNotPipelineOrMulti($caller) {if ($this->standalone && ($this->isMulti || $this->usePipeline) ||// phpredis triggers a php fatal error, so do the check before!$this->standalone && ($this->redis->getMode() === Redis::MULTI || $this->redis->getMode() === Redis::PIPELINE)) {throw new CredisException('multi()/pipeline() mode can not be used with ' . $caller);}}

报错是这个代码 "$this->redis->getMode()",其中$this->redis为空。

调用代码

$client = new Credis_Client();
$r = $client->select(15);
$data = $client->scan($client, "keywords:*", 1);
var_dump($data);

此时代码正常

$host = '127.0.0.1';
$port = 6379;
$timeout = null;
$persistent = '';
$db = 15;
$client = new Credis_Client($host,$port,$timeout ,$persistent,$db);$data = $client->scan($client, "keywords:*", 1);
var_dump($data);
var_dump(123);

会报上面的错误,就是Credis_Client构造里$this->redis没初始化。

使用懒加载,都是调用方法之后实现连接,实例化$this->redis。

可以按照正常顺序调用,也可以改代码。

修改后代码

protected function assertNotPipelineOrMulti($caller) {if (empty($this->redis)) {$this->connect();}if ($this->standalone && ($this->isMulti || $this->usePipeline) ||// phpredis triggers a php fatal error, so do the check before!$this->standalone && ($this->redis->getMode() === Redis::MULTI || $this->redis->getMode() === Redis::PIPELINE)) {throw new CredisException('multi()/pipeline() mode can not be used with ' . $caller);}}

http://www.dtcms.com/a/597296.html

相关文章:

  • 企业级SQL审核优化工具 PawSQL(4) — 生态集成
  • 太原建设工程信息网站appserv做网站教程
  • 【 Java 21 使用 JJWT 0.13.0的最新用法】
  • C++基础入门
  • 台州手机端建站模板松岗建设网站
  • 力扣(LeetCode)100题:239.滑动窗口最大值
  • TDengine 字符串函数 LENGTH 用户手册
  • Kotlin-协程的挂起与恢复
  • 莱州网站建设有限公司网站页面架构
  • 【Java SE 基础学习打卡】09 JRE 与 JDK
  • 无人机12V锂电池管理控制器方案学习,BQ40Z50
  • React核心概念Mutation
  • 企业建设好一个网站后_如何进行网站推广?网页设计大作业模板
  • VMware Ubuntu 22.04 NAT模式下配置GitHub SSH完整教程(含踩坑实录+报错_成功信息对照)
  • 文生图模型攻击论文原理笔记
  • Goer-Docker系统-1-Dockerfile的构建速度优化
  • 代做网页设计平台站长工具seo综合查询隐私查询导航
  • 方形与圆形滚珠导轨在工业场景如何选型?
  • UCOS-III笔记(一)
  • Unity:lua热更新(一)——AB包AssetBundle、Lua语法
  • 如何在Dev-C++中配置编译选项以支持C++11?
  • 海城区建设局网站快速百度
  • 网站怎样设计网址大全关键词排名提高方法
  • HOT100题打卡第36天——二分查找
  • 【Linux】Linux内存管理与线程控制核心解析
  • dns服务器
  • bash 启动程序的流程
  • 专题:2025中国医疗器械出海现状与趋势创新发展研究报告|附160+份报告PDF、数据、可视化模板汇总下载
  • 工程建设最好的网站石家庄建设网站哪家好
  • c#笔记之面向对象