webman中get请求包含参数名secret时报错,修改为其他则正常

dangpengsong

问题描述

这里写描述

如题当get请求中参数名包含secret时会报一个包冲突的错误
日志:
2023-04-08 07:34:21 pid:6796 Workerman[start.php] start in DEBUG mode
2023-04-08 07:34:37 pid:6803 Worker[6803] process terminated with ERROR: E_COMPILE_ERROR "Declaration of Symfony\Component\Cache\CacheItem::expiresAt(?DateTimeInterface $expiration): static must be compatible with PsrExt\Cache\CacheItemInterface::expiresAt($expiration) in /dota2helper/dota2server/vendor/symfony/cache/CacheItem.php on line 77"
2023-04-08 07:34:37 pid:6796 worker[webman:6803] exit with status 65280
有一点没搞明白,在本地虚拟机ubuntu中并未报此错误,同一套代码

程序代码或配置

{
  "name": "workerman/webman",
  "type": "project",
  "keywords": [
    "high performance",
    "http service"
  ],
  "homepage": "https://www.workerman.net",
  "license": "MIT",
  "description": "High performance HTTP Service Framework.",
  "authors": [
    {
      "name": "walkor",
      "email": "walkor@workerman.net",
      "homepage": "https://www.workerman.net",
      "role": "Developer"
    }
  ],
  "support": {
    "email": "walkor@workerman.net",
    "issues": "https://github.com/walkor/webman/issues",
    "forum": "https://wenda.workerman.net/",
    "wiki": "https://workerman.net/doc/webman",
    "source": "https://github.com/walkor/webman"
  },
  "require": {
    "php": ">=7.2",
    "workerman/webman-framework": "^1.4.3",
    "monolog/monolog": "^2.0",
    "psr/container": "^1.1.1",
    "illuminate/database": "^9.51",
    "illuminate/pagination": "^9.51",
    "illuminate/events": "^9.52",
    "symfony/var-dumper": "^6.0",
    "topthink/think-validate": "^2.0",
    "jasongrimes/paginator": "^1.0.3",
    "symfony/translation": "^6.0",
    "intervention/image": "^2.7",
    "vlucas/phpdotenv": "^5.5",
    "workerman/crontab": "^1.0",
    "teamones/response-code-msg": "^0.0.1",
    "webman/console": "^1.2",
    "webman/event": "^1.0",
    "webman/admin": "^0.5.8",
    "workerman/validation": "^3.0",
    "thiagoalessio/tesseract_ocr": "^2.7",
    "illuminate/redis": "^9.52",
    "symfony/cache": "^6.0",
    "yzh52521/webman-throttle": "^1.0",
    "phpmailer/phpmailer": "^6.8"
  },
  "suggest": {
    "ext-event": "For better performance. "
  },
  "autoload": {
    "psr-4": {
      "": "./",
      "app\\": "./app",
      "App\\": "./app",
      "app\\View\\Components\\": "./app/view/components"
    },
    "psr-0" : {
      "": "extend/"
    },
    "files": [
      "./support/helpers.php"
    ]
  },
  "scripts": {
    "post-package-install": [
      "support\\Plugin::install"
    ],
    "post-package-update": [
      "support\\Plugin::install"
    ],
    "pre-package-uninstall": [
      "support\\Plugin::uninstall"
    ]
  },
  "require-dev": {
    "phpunit/phpunit": "^9.6"
  }
}

public function config(Request $request)
{
    return json(['code' => self::SUCCESS, 'data' => time()]);
}

操作系统环境及workerman/webman等具体版本

Centos7
Workerman version:4.1.6 PHP version:8.0.18 Event-Loop:\Workerman\Events\Event

803 4 0
4个回答

dangpengsong

不支持gif动图啊......

  • 暂无评论
ichynul

第三方库的问题
Symfony\Component\Cache\CacheItem实现接口PsrExt\Cache\CacheItemInterfaceexpiresAt,但参数类型不一样。

  • 暂无评论
damao
有一点没搞明白,在本地虚拟机ubuntu中并未报此错误,同一套代码

说明本地php版本和线上不一致。
比如本地是php7.x,composer安装的组件是基于php7.x的。然后你把vendor都提交到了线上,线上是php8.x,
但是组件还是php7.x的组件,导致不兼容,就报错了。

开发一大忌就是本地php版本与线上php版本不一致。

  • dangpengsong 2023-04-08

    php版本完全一致,都是自己编译安装的

  • damao 2023-04-08

    执行 php -v 确认下

  • dangpengsong 2023-04-08

    确认过的都是PHP 8.0.18 NTS

  • damao 2023-04-08

    执行composer info 看下本地 symfony/cache 版本和线上版本是不是一样。

  • dangpengsong 2023-04-08

    已对比,composer info一致

  • dangpengsong 2023-04-08

    git推上去的,代码全部一致

  • dangpengsong 2023-04-08

    webman默认使用 symfony/cache作为cache组件,我先卸载 symfony/cache试试,看起来是 symfony/cache的一个潜在bug

dangpengsong

卸载symfony/cache后,问题消失,因为我的php版本比较低是8.0.18,symfony/cache在composer安装的时候提示不能安装最新的,是装了一个低版本的,这个低版本的在ubuntu中不会报错,但是在centos7中会报错,,只要php版本高装最新版或者用ubuntu应该都不会出现这个问题

  • 暂无评论
年代过于久远,无法发表回答
×
🔝