Search code examples
phpmagento

Purpose of /var/resource_config.json


I'm trying to figure out what the purpose of the file /var/resource_config.json is in Magento. It appears to perhaps be a caching of a configuration, but can't see where in the source code it is being created and/or updated.

I'm in the process of setting up local/dev/staging/prod environments for an EE1.12 build and want to figure out if I can safely exclude it from my repo or whether I need to script some updates to it for deploys.

Maybe the flash image uploader in admin creates it?

Any ideas or directions to look?


Solution

  • This is a configuration cache file for the "alternative media store" system. This is a system where requests for media files are routed through get.php, and allows you to store media in the database instead of the file system. (That may be a gross over simplification, as I've never used the feature myself)

    You can safely, (and should) exclude this file from deployments/source control, as it's a cache file and will be auto generated as needed. See the following codeblock in the root level get.php for more information.

    if (!$mediaDirectory) {
        $config = Mage_Core_Model_File_Storage::getScriptConfig();
        $mediaDirectory = str_replace($bp . $ds, '', $config['media_directory']);
        $allowedResources = array_merge($allowedResources, $config['allowed_resources']);
    
        $relativeFilename = str_replace($mediaDirectory . '/', '', $pathInfo);
    
        $fp = fopen($configCacheFile, 'w');
        if (flock($fp, LOCK_EX | LOCK_NB)) {
            ftruncate($fp, 0);
            fwrite($fp, json_encode($config));
        }
        flock($fp, LOCK_UN);
        fclose($fp);
    
        checkResource($relativeFilename, $allowedResources);
    }
    

    Speaking in general terms, Magento's var folder serves the same purpose as the *nix var folder

    Variable files—files whose content is expected to continually change during normal operation of the system—such as logs, spool files, and temporary e-mail files. Sometimes a separate partition

    and should be isolated to particular systems (i.e. not a part of deployments)