【问题标题】:Magento compiler - command lineMagento 编译器 - 命令行
【发布时间】:2012-10-10 11:42:18
【问题描述】:

当我通过命令行单击“shell”文件夹内的编译器状态时 我的商店,它返回编译器已启用,以便在管理员中启用,但是当我检查我的 Magento 站点的根文件夹中返回状态为禁用时!

$/var/www/magento# php shell/compiler.php 状态 编译器状态:禁用 编译状态:已编译 收集的文件数:6764 编译范围数:4 $/var/www/magento# cd shell/ $/var/www/magento/shell# php compiler.php 状态 编译器状态:已启用 编译状态:已编译 收集的文件数:6764 编译范围数:4

虽然我尝试通过关闭编译器模式、重新编译然后重新打开来解决此问题,但我得到了相同的结果!

【问题讨论】:

    标签: php magento command-line compiler-construction


    【解决方案1】:

    这“按设计工作”(只是设计不佳)。这是来自compiler.php 的用于确定状态的代码。

    $compilerConfig = '../includes/config.php';
    if (file_exists($compilerConfig)) {
        include $compilerConfig;
    }
    $status = defined('COMPILER_INCLUDE_PATH') ? 'Enabled' : 'Disabl    ed';
    

    关键行是$compilerConfig = '../includes/config.php';。此路径从当前目录向上一个目录以找到config.php。 PHP shell 脚本的工作目录是它从中调用的目录,而不是它所在的目录。所以你说

    $/var/www/magento# php shell/compiler.php state
    

    脚本在

    中查找文件
    /var/www/magento/../includes/config.php
    

    /var/www/includes/config.php
    

    因为它没有找到,所以它假定为禁用状态。

    【讨论】:

    • 看不出两个答案之间的区别,但足够公平。 :)
    【解决方案2】:

    编辑includes/config.php 并注释掉两个define 行。这就是 Magento 为启用/禁用编译器所做的一切。

    http://svn.magentocommerce.com/source/branches/1.7/includes/config.php

    来自shell/compiler.php的代码sn-p

    $compiler = $this->_getCompiler();
    $compilerConfig = '../includes/config.php';
    if (file_exists($compilerConfig)) {
        include $compilerConfig;
    }
    $status = defined('COMPILER_INCLUDE_PATH') ? 'Enabled' : 'Disabled';
    

    另外我建议只使用APC 或任何其他 OPCode 缓存,因为它可以解决同样的问题,而且不会那么麻烦。

    【讨论】:

      【解决方案3】:

      我意识到这是一篇旧帖子,但看起来这个错误仍然存​​在于 Magento 1.9 中。 如果您希望能够从其他目录检查您的编译器状态,只需修改此行:

      $compilerConfig = '../includes/config.php';
      

      改成

      $compilerConfig = dirname(__FILE__).'/../includes/config.php';
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-30
        • 1970-01-01
        • 1970-01-01
        • 2010-12-02
        相关资源
        最近更新 更多