【问题标题】:Debugging PHP Error: Ajax Chat installation调试 PHP 错误:Ajax 聊天安装
【发布时间】:2015-09-10 19:56:46
【问题描述】:

无法为 Ajax 聊天运行安装脚本。看来函数调用可以找到适当的 $filename,所以我无法确定无效参数是什么。

in file [ROOT]/phpbb/di/container_builder.php on line 291: file_put_contents(C:/inetpub/wwwroot/phpbb3/chat/../cache/container_C:/inetpub/wwwroot/phpbb3/chatslashdotdotslash.php): failed to open stream: Invalid argument

这是第 284-291 行:

protected function dump_container($container_filename)
{
    $dumper = new PhpDumper($this->container);
    $cached_container_dump = $dumper->dump(array(
        'class'         => 'phpbb_cache_container',
        'base_class'    => 'Symfony\Component\DependencyInjection\ContainerBuilder',
    ));
    file_put_contents($container_filename, $cached_container_dump);
}

$container_filename 的函数调用是

protected function get_container_filename()
{
    $filename = str_replace(array('/', '.'), array('slash', 'dot'), $this->phpbb_root_path);
    return $this->phpbb_root_path . 'cache/container_' . $filename . '.' . $this->php_ext;
}

我认为 $cached_container_dump 的函数变量可能是问题所在,如上面第 2 行所示。我不确定是否找到了 base_class,因为它不在命名空间中。几天来一直试图遵循这个......任何帮助将不胜感激。

var_dump($dumper) 的结果:这是否意味着数组正在返回一个对象?

object(Symfony\Component\DependencyInjection\Dumper\PhpDumper)#13 (7) { ["inlinedDefinitions":"Symfony\Component\DependencyInjection\Dumper\PhpDumper":private]=> object(SplObjectStorage)#3325 (1) { ["storage":"SplObjectStorage":private]=> array(198) 

【问题讨论】:

    标签: php ajax symfony


    【解决方案1】:

    将您的 file_put_contents 函数替换为以下函数:

    file_put_contents($container_filename, $cached_container_dump, FILE_APPEND);
    

    并确保$dumper->dump() 函数返回一个字符串。

    【讨论】:

    • 嗯。我已经对函数进行了更改,但我不清楚 $dumper->dump()。看起来它返回了一个数组,但我想我将不得不追踪“base_class”,因为我不确定该数组在那里设置了什么。
    【解决方案2】:

    您必须将冒号替换为缓存文件名,因为它不是 Windows 上的有效文件名字符。

    【讨论】:

    • 也许我遗漏了一些东西,但我没有在任何缓存文件名中看到冒号?
    • 您从$this->phpbb_root_path 生成$filename 变量,该变量似乎包含c:,您可以看到.../cache/container_C:/inetpub/... 的错误消息。有趣的是,尽管您尝试替换斜线,但它仍然包含斜线。也许您应该检查是否调用了get_container_filename(),如果是,设置后$filename的内容是什么。
    猜你喜欢
    • 2010-11-08
    • 2011-07-12
    • 2017-09-10
    • 1970-01-01
    • 1970-01-01
    • 2011-05-30
    • 1970-01-01
    • 2013-01-28
    • 2023-03-19
    相关资源
    最近更新 更多