Search code examples
phpsymfony1symfony-1.4tmp

Symfony app writing config files to tmp directory


I've inherited an old Symfony app (Symfony 1.4) and had to migrate it to a new server. I have no experience with Symfony, but the migration went well and everything works fine except one thing; the new server's admin(s) complain about the app writing files to /tmp directory every minute:

Partial sample output from admins:

-rw-------  1 www-data  www-data      17133 Dec 18 14:45 config_routing.yml.php4VSPbj
-rw-------  1 www-data  www-data      17133 Dec 18 14:47 config_routing.yml.php8ZZlxn
-rw-------  1 www-data  www-data      17133 Dec 18 14:38 config_routing.yml.php9NH03d
-rw-------  1 www-data  www-data      17133 Dec 18 14:38 config_routing.yml.phpGA9YrM
-rw-------  1 www-data  www-data      17133 Dec 18 14:45 config_routing.yml.phpO9fYz5
-rw-------  1 www-data  www-data      17133 Dec 18 14:47 config_routing.yml.phpOiXAYC
-rw-------  1 www-data  www-data      17133 Dec 18 14:43 config_routing.yml.phpptNyFw

and these files as well:

config_settings.yml.php, config_databases.yml.php, config_autoload.yml.php.

I've made sure debugging is disabled in prod environment, but this still happens. Does anyone have any clue to what might be causing this?


Solution

  • It seems the applications cache directory does not exists, tempnam() function used by sfConfigCache class then defaults to using system temp directory.

    The default location is ./cache, create it and make it writable by apache.

    To understand what is happening, snippets from sfConfigCache class:

    Line 344: $tmpFile = tempnam(dirname($cache), basename($cache)); Here the /tmp/config_routing.yml.php* files are created, to be renamed or copied few lines later:

    if (!@rename($tmpFile, $cache))
    {
      if (copy($tmpFile, $cache))
      {
        unlink($tmpFile);
      }
    }
    

    Obviously, both rename and copy failed.