Temporary File Management
Understand Pantheon's default temporary path and learn how to debug .tmp file errors.
This section provides information on how to use and debug the default temporary path, .tmp
.
This doc uses Terminus commands. Before you begin, set the variables $site
and $env
in your terminal session to match your site name and the correct environment:
export env=dev
Default Temporary Path
WordPress
You can get the Pantheon-configured temporary path for WordPress on the Pantheon Systems WordPress Github.
Drupal
We don't recommend changing the temporary settings path for Drupal. Changing the configuration allows temporary files to be shared across application containers, but heavily impacts performance.
Add the code below to your settings.php
file to get the appropriate configuration for Drupal sites.
/**
* Drupal
* Define appropriate location for tmp directory
*/
if (isset($_ENV['PANTHEON_ENVIRONMENT'])) {
if (isset($_SERVER['PRESSFLOW_SETTINGS'])) {
// It's necessary to unset the injected PRESSFLOW_SETTINGS to override the values.
$pressflow_settings = json_decode($_SERVER['PRESSFLOW_SETTINGS'], TRUE);
unset($pressflow_settings['conf']['file_temporary_path']);
unset($pressflow_settings['conf']['file_directory_temp']);
$_SERVER['PRESSFLOW_SETTINGS'] = json_encode($pressflow_settings);
}
$conf['file_temporary_path'] = $_SERVER['HOME'] .'/tmp';
$conf['file_directory_temp'] = $_SERVER['HOME'] .'/tmp';
}
Fix Unsupported Temporary Path
Errors caused by an unsupported temporary path typically surface as permission errors for .tmp
files and can be replicated on any environment.
You must correct an unsupported temporary path set by a plugin or theme in the wp-config.php
file.
Replace
SOME_TMP_SETTING
with the conflicting plugin or theme option. For example:if (isset($_ENV['PANTHEON_ENVIRONMENT'])) { define('SOME_TMP_SETTING', $_SERVER['HOME'] . '/tmp'); }
Run
wp config get
in Terminus to verify the setting:terminus wp $site.$env -- config get SOME_TMP_SETTING
The output for this command should look similar to the following Contact Form 7 example:
You must correct an unsupported temporary path set by a module or theme using $conf
override in the settings.php
file.
Replace
some_tmp_setting
with the conflicting module or theme setting. For example:if (isset($_ENV['PANTHEON_ENVIRONMENT'])) { $conf['some_tmp_setting'] = $_SERVER['HOME'] . '/tmp'; }
Run
drush variable-get
in Terminus to verify the setting:terminus drush $site.$env -- variable-get some_tmp_setting
The output for this command should look similar to the following Plupload example:
You must correct an unsupported temporary path set by a module or theme using $settings
override in the settings.php
file.
Replace
file_temp_path
with the conflicting module or theme setting:if (isset($_ENV['PANTHEON_ENVIRONMENT'])) { $settings['file_temp_path'] = $_SERVER['HOME'] . '/tmp'; }
Run
drush config:get
in Terminus to verify the setting:terminus drush $site.$env -- config:get some_tmp_setting
Multiple Application Containers
Errors caused by this scenario occur on production environments (Test or Live) and typically reference some .tmp
file as not found and could not be copied. These errors cannot be replicated on development environments (Dev or Multidev) because those environments use a single application container.
Sites on the Performance Medium plan and above have multiple application containers. The platform routes requests across available application containers based on their load to help sites perform at scale.
The default temporary path ($_SERVER['HOME'] . '/tmp'
) is not synchronized across application containers which causes operations that expect this path to persist will fail.
Considerations
It's uncommon for a plugin, module, or theme to use the temporary path in a way that results in such errors. We suggest reporting the issue to the author and replacing the conflicting plugin, module, or theme whenever possible until a fix is released.
Be aware that temporary files are not cleaned up automatically in the following configuration, which can result in highly populated directories.
Persistent Temporary Path Workaround
There's generally no need for temporary files to persist across application containers. You can use a different plugin or module to avoid a performance hit that accompanies the workaround below.
You must configure a temporary path that uses a private subdirectory of Pantheon's networked filesystem in the wp-config.php
file.
Verify that you have the
private
andtmp
directories. These directories do not exist by default. You must create the folders via SFTP if you have not done so already. We do not recommend using a public path because core treats the temporary path as non-web-accessible by default.Replace
SOME_TMP_SETTING
with the conflicting plugin or theme option:if (isset($_ENV['PANTHEON_ENVIRONMENT'])) { define('SOME_TMP_SETTING', '/wp-content/uploads/private/tmp'); }
Run
wp config get
in Terminus to verify the setting:terminus wp $site.$env -- config get SOME_TMP_SETTING
The output for this command should look similar to the following Contact Form 7 example:
You must configure a temporary path that uses a private subdirectory of Pantheon's networked filesystem using the $conf
override in the settings.php
file.
Verify that you have the
private
andtmp
directories. These directories do not exist by default. You must create the folders via SFTP if you have not done so already. We do not recommend using a public path because core treats the temporary path as non-web-accessible by default.Replace
some_tmp_setting
with the conflicting module or theme setting:if (isset($_ENV['PANTHEON_ENVIRONMENT'])) { $conf['some_tmp_setting'] = 'sites/default/files/private/tmp'; }
Run
drush variable-get
in Terminus to verify the setting:terminus drush $site.$env -- variable-get some_tmp_setting
The output for this command should look similar to the following Plupload example:
You must configure a temporary path that uses a private subdirectory of Pantheon's networked filesystem using the $settings
override in the settings.php
file.
Verify that you have the
private
andtmp
directories. These directories do not exist by default. You must create the folders via SFTP if you have not done so already. We do not recommend using a public path because core treats the temporary path as non-web-accessible by default.Replace
file_temp_path
with the conflicting module or theme setting:if (isset($_ENV['PANTHEON_ENVIRONMENT'])) { $settings['file_temp_path'] = 'sites/default/files/private/tmp'; }
Run
drush config:get
in Terminus to verify the setting:terminus drush $site.$env -- config:get some_tmp_setting