Development

#4696 (Clear Cache task will fail under certain conditions)

You must first sign up to be able to contribute.

Ticket #4696 (new defect)

Opened 2 years ago

Last modified 2 years ago

Clear Cache task will fail under certain conditions

Reported by: Sapheriel Assigned to: fabien
Priority: major Milestone:
Component: cache Version: 1.1.4
Keywords: Cc:
Qualification: Unreviewed

Description

Symfony's clear cache task will fail when trying to clear config cache files created by another user (ie. web server) when there are config files that are newer than the cached versions.

./symfony cc
>> cache     Clearing cache type "all" for "frontend" app and "prod" env

Failed to write cache file "/var/www/promotions/current/cache/frontend/prod/config/config_settings.yml.php" generated from configuration file "config/settings.yml".  

Analysis:

While cache folders are created with full permissions (777, or umask 000) the cache files are created with default permissions (644, or umask 022).

When the clear cache task executes, it iterates through all cached applications and environments and loads the configuration for each before doing the actual cleaning.

Because it loads the application configuration with debug mode turned on, sfConfigCache will check if any of the config files are newer than the cached version and reprocess each such file it finds.

Since the task runs under a user different from the owner of the config cache files, writing the new config cache file fails.

Stack trace:

  at /var/www/promotions/current/lib/symfony/config/sfConfigCache.class.php:344
 sfConfigCache->writeCacheFile at /var/www/promotions/current/lib/symfony/config/sfConfigCache.class.php:107
 sfConfigCache->callHandler at /var/www/promotions/current/lib/symfony/config/sfConfigCache.class.php:194
 sfConfigCache->checkConfig at /var/www/promotions/current/lib/symfony/config/sfApplicationConfiguration.class.php:113
 sfApplicationConfiguration->initConfiguration at /var/www/promotions/current/lib/symfony/config/sfApplicationConfiguration.class.php:49
 sfApplicationConfiguration->__construct at /var/www/promotions/current/lib/symfony/config/sfProjectConfiguration.class.php:342
 sfProjectConfiguration::getApplicationConfiguration at /var/www/promotions/current/lib/symfony/task/cache/sfCacheClearTask.class.php:104
 sfCacheClearTask->execute at /var/www/promotions/current/lib/symfony/task/sfBaseTask.class.php:77
 sfBaseTask->doRun at /var/www/promotions/current/lib/symfony/task/sfTask.class.php:75
 sfTask->runFromCLI at /var/www/promotions/current/lib/symfony/command/sfSymfonyCommandApplication.class.php:72
 sfSymfonyCommandApplication->run at /var/www/promotions/current/lib/symfony/command/cli.php:20
 include at /var/www/promotions/current/symfony:15

Proposed solutions:

Create the config cache files with full write permissions. Since the cache folders already have full write permissions and the sticky bit doesn't get set, everyone can delete cache files and then create another file with the same name. Therefore, it shouldn't make a difference from a security standpoint.

Alternatively, unlink the existing file before writing the new one.

Change History

10/17/08 17:41:05 changed by Sapheriel

Here how to reproduce the problem:

  1. clear cache manually: rm -rf cache/*
  2. make a request through your browser to any application
  3. change the mod time on any config file that is required to build the application configuration for that application: touch apps/frontend/config/settings.yml

(follow-up: ↓ 3 ) 10/17/08 17:54:05 changed by michael.piecko

  • priority changed from minor to major.
  • version changed from 1.1.4 to 1.2.0 DEV.
  • component changed from other to cache.

And i thought i messed it up using my custom cache structure ... The same with me. I can reproduce this error on my linux box.

Michael

(in reply to: ↑ 2 ) 10/17/08 17:54:53 changed by michael.piecko

  • version changed from 1.2.0 DEV to 1.1.4.

Replying to michael.piecko:

And i thought i messed it up using my custom cache structure ... The same with me. I can reproduce this error on my linux box. Michael

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.