2012-10-10 64 views
0

當我 我的存儲根點擊「殼」文件夾中的編譯器狀態的命令行,它返回的編譯器被啓用,因此在管理,但是當我檢查的我的Magento網站的根文件夾是返回狀態被禁用!Magento的編譯器 - 命令行

 
$/var/www/magento# php shell/compiler.php state 
Compiler Status:   Disabled 
Compilation State:  Compiled 
Collected Files Count: 6764 
Compiled Scopes Count: 4 
$/var/www/magento# cd shell/ 
$/var/www/magento/shell# php compiler.php state 
Compiler Status:   Enabled 
Compilation State:  Compiled 
Collected Files Count: 6764 
Compiled Scopes Count: 4 

雖然我就會把編譯器模式關閉,重新編譯,然後打開它回到解決這個問題,我得到了相同的結果!

回答

0

這個「作品爲設計」(除了它只是設計不當)。這裏是來自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 

,因爲它沒有找到一個,它假定的禁用狀態。

+1

實在看不出這兩個答案,但很公平的區別。 :) – B00MER

0

編輯includes/config.php並註釋掉兩條define線。這是所有Magento用來啓用/禁用編譯器的。從shell/compiler.php

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

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

代碼段還我建議只使用APC或任何其他操作碼緩存,因爲它會解決辦法少頭疼了同樣的問題。

0

我意識到這是舊的文章,但它看起來像這樣的錯誤仍然存​​在在Magento 1.9。 如果你希望能夠檢查從其他目錄編譯器的狀態,只需修改這一行:

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

變化

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