我正在 DDEV (Docker) 开发环境中开发旧版本的 ILIAS 5.4。这是一个用 PHP 编写的L赚钱M管理S系统。运行时环境包括:
目前我偶然发现了一个关于
APCUIterator
的错误,我不知道如何处理。关于 while 子句,在迭代器上调用 key()
方法
/**
* @param bool $complete
*
* @return bool
*/
public function flush($complete = false)
{
if ($complete) {
return apcu_clear_cache();
}
$key_prefix = $this->returnKey('');
$apcu_iterator = new APCUIterator();
$apcu_iterator->rewind();
while ($current_key = $apcu_iterator->key()) {
// "begins with"
if (substr($current_key, 0, strlen($key_prefix)) === $key_prefix) {
$this->delete($current_key);
}
$apcu_iterator->next();
}
return true;
}
错误消息显示:无法在无效迭代器上调用 key() —在容器内,我可以使用以下提取的代码片段重现错误
<?php
$iterator = new APCUIterator();
$iterator->key();
# Nothing else matters
产生的错误在浏览器中呈现如下屏幕截图
我最好的猜测是容器内缺少一些东西。依赖项或配置。有什么建议吗?
编辑: 以下是与 APC 配置相关的
ddev php -i | grep -i apc
输出。
/etc/php/7.3/cli/conf.d/20-apcu.ini,
/etc/php/7.3/cli/conf.d/25-apcu_bc.ini,
/etc/php/7.3/cli/conf.d/enableapcu.ini,
apc
APC Compatibility => 1.0.5
apcu
APCu Support => Enabled
APCu Debugging => Disabled
apc.coredump_unmap => Off => Off
apc.enable_cli => On => On
apc.enabled => On => On
apc.entries_hint => 4096 => 4096
apc.gc_ttl => 3600 => 3600
apc.mmap_file_mask => no value => no value
apc.preload_path => no value => no value
apc.serializer => php => php
apc.shm_segments => 1 => 1
apc.shm_size => 32M => 32M
apc.slam_defense => Off => Off
apc.smart => 0 => 0
apc.ttl => 0 => 0
apc.use_request_time => Off => Off
igbinary APCu serializer ABI => 0
编辑 2: 以下是基于 Debian 和 Apache Web 服务器的本机暂存系统(不是 Docker)的与 APC 配置相关的
php -i | grep -i apc
输出。
/etc/php/7.3/cli/conf.d/20-apcu.ini,
apcu
APCu Support => Disabled
APCu Debugging => Disabled
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On
apc.entries_hint => 4096 => 4096
apc.gc_ttl => 3600 => 3600
apc.mmap_file_mask => no value => no value
apc.preload_path => no value => no value
apc.serializer => php => php
apc.shm_segments => 1 => 1
apc.shm_size => 32M => 32M
apc.slam_defense => Off => Off
apc.smart => 0 => 0
apc.ttl => 0 => 0
apc.use_request_time => On => On
在
$apcu->current()
上遇到同样的问题。
避免这种情况的一种方法是尝试
$apcu->valid()
,它应该返回 true
:
$apcu_iterator = new APCUIterator();
if ($apcu_iterator->valid()) {
// do stuff on iterator
}
我不知道为什么它返回一个无效的迭代器。我在两台不同的服务器上禁用了
APCu Support
,一台工作正常,另一台则不行...