Question

I'm attempting to programmatically determine if Magento's compilation status is enabled or disabled. I found the function getCompilerStatus() in app/design/adminhtml/default/default/template/compiler/process.phtml that allows you to determine the status in the admin panel. I am however trying to run this from a "workbench" script outside of the admin panel. Here is what I have:

<?php
ini_set('display_errors',1); 
error_reporting(E_ALL);

# workebench script
require_once('app/Mage.php');
umask(0);
Mage::app();

echo "Checking Compilation Status<br />";

// Code that would work in admin panel
echo $this->getCompilerStatus();

The result: Fatal error: Using $this when not in object context

So I Googled the function and came across the following link from Magento which shows the "Varien Objects" required: http://docs.magentocommerce.com/Mage_Compiler/Mage_Compiler_Block_Process.html#getCompilerStatus

From this it appears that I need to load Mage_Core_Block_Abstract, Mage_Core_Block_Template and I'm assuming I can drop Mage_Adminhtml_Block_Template as my function does not require the admin panel.

Can anyone tell me if I'm going about this the right way? Thank you.

Was it helpful?

Solution

Actually that method just checks if the constant COMPILER_INCLUE_PATH is defined.

The only place where this seems to be set is includes/config.php. So I've never used the compiler, but it looks like that this file is modified when the compiler is activated, so I would include it and after that check as in the method if the constant is defined.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top