从 PHP 7.4.1 开始,即使他们说它已修复,最新版本也存在梨形错误。
示例:如果您尝试使用“pecl”安装任何软件包,则会返回警告错误并显示以下消息:
Notice: Trying to access array offset on value of type bool in PEAR/REST.php on line 187
PHP Notice: Trying to access array offset on value of type bool in /usr/share/php/PEAR/REST.php on line 187
Run Code Online (Sandbox Code Playgroud)
存储库已经更新,但问题仍然存在
Kev*_*vin 19
我遇到了同样的问题,创建临时梨缓存目录解决了它。
mkdir -p /tmp/pear/cache
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题。
Notice: Trying to access array offset on value of type bool in REST.php on line 181
PEAR Version: 1.10.1
PHP Version: 7.4.1
Zend Engine Version: 3.4.0
Running on: Darwin kairee-mbp 19.2.0 Darwin Kernel Version 19.2.0
Run Code Online (Sandbox Code Playgroud)
PEAR Version: 1.10.1
PHP Version: 7.4.1
Zend Engine Version: 3.4.0
Running on: Darwin kairee-mbp 19.2.0 Darwin Kernel Version 19.2.0
Run Code Online (Sandbox Code Playgroud)
您可能会注意到,当缓存文件不存在时,getCacheId将返回false. 在第 181 行,代码if (time() - $cacheid['age'] < $cachettl) {试图访问 上的数组偏移量false。
我向这一行添加了一个条件来修复它:
function useLocalCache($url, $cacheid = null)
{
if (!is_array($cacheid)) {
$cacheid = $this->getCacheId($url);
}
$cachettl = $this->config->get('cache_ttl');
// If cache is newer than $cachettl seconds, we use the cache!
if (time() - $cacheid['age'] < $cachettl) {
return $this->getCache($url);
}
return false;
}
/**
* @param string $url
*
* @return bool|mixed
*/
function getCacheId($url)
{
$cacheidfile = $this->config->get('cache_dir') . DIRECTORY_SEPARATOR .
md5($url) . 'rest.cacheid';
if (!file_exists($cacheidfile)) {
return false;
}
$ret = unserialize(implode('', file($cacheidfile)));
return $ret;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9582 次 |
| 最近记录: |