diem-project/diem — Issue #416: Web cache directory permissions not properly set by the task 'dm:permissions'
Author: kisskrool
Created: 2011-10-13 09:06:53+00:00
State: open

Hi,

I have tried to set the permissions of the folders using the diem command 'dm:permissions' ie. by the class dmCorePlugin/lib/task/dmProjectPermissionsTask.php in diem 5.1.3. Neither this class or the parent one -which sets the right permission for the sf_root_dir/cache directory- alters the folder sf_web_dir/cache

I propose the following addition to solve the problem which obviously still exists in 'master' branch (which if I'm right corresponds to 5.1.4).

Here is my code:

protected function execute($arguments = array(), $options = array())
{
$this->logSection('diem', 'Check file permissions');
parent::execute();

$this->chmod(sfConfig::get('sf_web_dir').'/cache', 0777); //added

$this->current = null;
$this->failed = array();

$dirs = array(
sfConfig::get('sf_apps_dir'),
sfConfig::get('sf_lib_dir'),
sfConfig::get('sf_data_dir'),
sfConfig::get('sf_web_dir').'/cache' //added
);

$dirFinder = sfFinder::type('dir');
$fileFinder = sfFinder::type('file');

foreach ($dirs as $dir)
{
$this->chmod($dirFinder->in($dir), 0777);
$this->chmod($fileFinder->in($dir), 0666);
}

// note those files that failed
if (count($this->failed))
{
$this->logBlock(array_merge(
array('Permissions on the following file(s) could not be fixed:', ''),
array_map(create_function('$f', 'return \' - \'.sfDebug::shortenFilePath($f);'), $this->failed)
), 'ERROR_LARGE');
}
}

Regards,

kisskrool