我今天从 L5.5 升级到了 L5.6(正在将 Symfony 组件更新到 v4)。从官方 Laravel 5.6 升级指南开始,我也将fideloper/proxy
包更新到 4.0。
之后,我开始收到此错误:Type error: Argument 2 passed to Symfony\Component\HttpFoundation\Request::setTrustedProxies() must be of the type integer, array given, called in /var/www/html/vendor/fideloper/proxy/src/TrustProxies.php on line 54
Symfony 4Symfony\Component\HttpFoundation\Request::setTrustedProxies()
确实期望整数(位掩码)作为第二个参数:
/**
* Sets a list of trusted proxies.
*
* You should only list the reverse proxies that you manage directly.
*
* @param array $proxies A list of trusted proxies
* @param int $trustedHeaderSet A bit field of Request::HEADER_*, to set which headers to trust from your proxies
*
* @throws \InvalidArgumentException When $trustedHeaderSet is invalid
*/
public static function setTrustedProxies(array $proxies, int $trustedHeaderSet)
{
self::$trustedProxies = $proxies;
self::$trustedHeaderSet = $trustedHeaderSet;
}
和fideloper/proxy
4.0 确实是给这个函数一个数组而不是一个整数:
public function handle(Request $request, Closure $next)
{
$request::setTrustedProxies([], $this->getTrustedHeaderNames()); // Reset trusted proxies between requests
$this->setTrustedProxyIpAddresses($request);
return $next($request);
}
和
/**
* Retrieve trusted header name(s), falling back to defaults if config not set.
*
* @return array
*/
protected function getTrustedHeaderNames()
{
return $this->headers ?: $this->config->get('trustedproxy.headers');
}
所以我不明白这是错误fideloper/proxy
还是我只是错过了什么?