路由中间件,使用数组方式传参,再进行 withoutMiddleware 排除中间件 异常
所属功能组件
路由(Route)
ThinkPHP 版本
8.1
操作系统
macos
错误信息
如果在路由中间件中,使用数组方式传参,再进行 withoutMiddleware 排除中间件时 报错,如图片
其它说明
No response
1月26日的BUG,现在还没解决,官方不维护了么? 文件【vendor/topthink/framework/src/think/route/Dispatch.php】97行改为:$middleware = !empty($option['without_middleware']) ? array_diff(array_map(fn($item) => $item[0], $option['middleware']), $option['without_middleware']) : [];
确实是有问题,在$option['middleware']列表出现数组的时候,array_diff的时候报错Array to string conversion
$middleware = !empty($option['without_middleware']) ? array_diff(array_map(fn($item) => $item[0], $option['middleware']), $option['without_middleware']) : [];
这样改还是有个问题,如果中间件是闭包的情况,会报错误Object of class Closure could not be converted to string