Hi Ian, Fabien..
I have found the bug regarding cache inconsistency using admin generator.
Let's think together about the right solution as I really do not think I
know enough about the internals of symfony.
As I see it, it might just be a misconfiguration of cache when
instantiated for admin-generator or an unforeseen sideeffect of
automaticCleaningFactor + lifeTime cache configuration options..
I have managed to reproduce this error using the Zend debugger. This is
what happens:
1. Cache for admin generator is created for each module the first time
any of it's actions is called.
2. When sfGeneratorManager initiates, it instantiates a sfFileCache
without any options, which means that default value of 500 is taken for
"automaticCleaningFactor"
class sfGeneratorManager
{
protected $cache = null;
/**
* Initializes the sfGeneratorManager instance.
*/
public function initialize()
{
// create cache instance
$this->cache = new sfFileCache(sfConfig::get('sf_module_cache_dir'));
$this->cache->setSuffix('');
}
3. sfGenerator.php writes cache files using sfFileCache instantiated
with automaticCleaningFactor = 500
/**
* Generates PHP files for a given module name.
*
* @param string The name of module name to generate
* @param array A list of template files to generate
* @param array A list of configuration files to generate
*/
protected function generatePhpFiles($generatedModuleName,
$templateFiles = array(), $configFiles = array())
{
// eval actions file
$retval = $this->evalTemplate('actions/actions.class.php');
// save actions class
$this->getGeneratorManager()->getCache()->set('actions.class.php',
$generatedModuleName.DIRECTORY_SEPARATOR.'actions', $retval);
// generate template files
foreach ($templateFiles as $template)
{
// eval template file
$retval = $this->evalTemplate('templates/'.$template);
// save template file
$this->getGeneratorManager()->getCache()->set($template,
$generatedModuleName.DIRECTORY_SEPARATOR.'templates', $retval);
}
// generate config files
foreach ($configFiles as $config)
{
// eval config file
$retval = $this->evalTemplate('config/'.$config);
// save config file
$this->getGeneratorManager()->getCache()->set($config,
$generatedModuleName.DIRECTORY_SEPARATOR.'config', $retval);
}
}
4. inside the set() function of sfFileCache there is code that every
500th time clears the cache directory of "old" files which are "old"
when older than lifeTime which in this case also has defaulted to 86400
seconds
5. Conclusion:
Lets say we have 2 modules, 1 and 2. We start from a symfony clear-cache!
If I call any action in module 1 (and thus it's cache is generated) 1
day before the first time I call any action in module 2, so module 2
generates it's cache 1 day after the module 1. In this case there is 1
in 500 chance that cache generation of the module 2 will erase the "old"
files which belong to the module 1 which has been generated more than 1
day ago. Once the actions file of admin-generated cache is missing it
will never be regenerated again because the module.yml file is still in
the cache. So the temporary solution for this was to clear the whole cache.
Since our app has a lot of modules this has occured very often recently.
Any sugestions on how to fix this?!
A quick fix for me would be to initiate the sfFileCache inside
sfGeneratorManager with automaticCleaningFactor = 0 :)
What do you think the right solution would be?
regards
Haris
Ian P. Christian wrote:
> Haris Zukanovic' wrote:
>
>> I apologize, for not being precise..
>> I was refering to where inside the symfony code does symfony do the
>> cache regeneration?
>> I wish to trace these thing because I am having big problems with
>> inconsistent cache fron time to time, rendering my symfony site unusable
>>
>
> This is a long standing problem in symfony, that has never been tracked
> down - have you found a consistent way of causing this problem?
>
>
--
Haris Zukanovic
CEO
Software development and research
International Business Development, SOFTING ltd.
office +387 36 318 339
GSM +387 61 839 069
http://www.eu-softing.com
CONFIDENTIALITY NOTICE
This e-mail and any attached files, sent by a company e - mail system, contains
company confidential and/or privileged information and is intended only for the
person or entity to which it is addressed and only for the purposes therein set
forth. If you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure, distribution or other use of, or taking of
any action in reliance upon, the material in this e-mail by persons or entities
other than the intended recipient is strictly forbidden.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---