Important
EOL notice! Drupal 8 reached end-of-life on November 2, 2021. Therefore, Acquia will not be performing any testing related to Drupal 8 to ensure compatibility. Acquia recommends upgrading to Drupal 9 or later. For more information, see Frequently Asked Questions.
When using Site Factory, you cannot directly modify your
website’s settings.php
file, but you can make changes to values in
settings.php
using hooks at the beginning and end of the settings.php
file. These hooks enable you to run custom code during your website’s
bootstrap process.
Note
Files executed by settings.php
hooks must have a .php
extension.
Due to every web request running the commands in settings.php
hooks, commands included in settings.php
hooks must be lightweight
(for example, setting variables) and must not read or write to databases
or files. Accessing databases or files using the hook file can greatly
impair your website’s performance. If you must access databases or files,
you must use modules instead.
Like several of the other hooks in use by Site Factory, you must create a script file and then place it in a particular directory. The scripts run in alphabetical order at the appropriate time when doing database updates for your websites.
For detailed instructions, see Hooks in Site Factory.
Modify the following script to suit your needs in pre-settings-php
hooks:
Certain pages on your websites may require increased memory limits to function properly. To increase the memory limit on your websites, use the following script:
<?php
/**
* Sets a higher memory limit for admin/structure/menu which frequently
* needs an unusually high amount of memory to load, due to complexity.
* For additional examples of changing memory limits for pages on
* your websites, see
* https://support-acquia.force.com/s/article/360004542293-Conditionally-increasing-memory-limits
*/
if (strpos($_GET['q'], 'admin/structure/menu/') === 0) {
ini_set('memory_limit', '700M');
}
For additional examples, see Examples of conditional memory limit changes.
Modify the following scripts to suit your needs in post-settings-php
hooks:
To enable memcache on your Site Factory websites:
Contact your Technical Account Manager or Account Manager to discuss your subscription’s hardware needs.
Install the Memcache API and Integration module to your codebase.
Modify the following script to provide the necessary configuration details:
$conf['cache_backends'][] = '<path to the memcache.inc file>';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
For complete information about enabling memcached, see Enabling Memcached on Cloud Platform.
To import configuration values into an Site Factory website, edit the following script to point to the directory (or directories) where your configuration values are stored:
Important
Drupal 8.8.0
deprecated $config_directories
. The sync
directory and vcs
directory paths are now defined as values in the $settings
array:
$settings['config_sync_directory'] = 'your/config/sync/directory/path'
$settings['config_vcs_directory'] = 'your/config/vcs/directory/path'
For earlier versions of Drupal 8, use the following code:
<?php
/**
* Set vcs and sync dirs to writable directories above docroot.
*/
$config_directories['vcs'] = '../config/default';
$config_directories['sync'] = '../config/default';
If the config
directory does not already exist, you must create it in
the same folder containing your docroot
directory, as in this example:
/docroot/
config/default/
To conditionally set the cache lifetime of each website in your
Site Factory subscription to individual values, and disallowing
any value of fewer than 5 minutes, download this example
acsf-cache-lifetime.php
script.
To enable New Relic monitoring in a
multisite environment, like Site Factory, create a
post-settings.php
script named new_relic.php
containing the
following code, replacing current_app_name
with the name of your
application:
if (extension_loaded('newrelic')) {
$env = 'local';
if (isset($_ENV['AH_SITE_ENVIRONMENT'])) {
$env = $_ENV['AH_SITE_ENVIRONMENT'];
}
global $_acsf_site_name;
newrelic_set_appname("<current_app_name>.$env.$_acsf_site_name; <current_app_name>.$env", '', 'true');
}
If you must store sensitive credentials outside of your codebase, you can
create a secrets.settings.php
file and then make its contents available to
Drupal with a post-settings.php
hook (as described in
Storing sensitive information outside of your codebase). By doing so, sensitive credentials are not kept in
your database backups or your version control repository, allowing you to
distribute database backups or grant repository access to team members who
must not possess sensitive credentials.
You can minimize database deadlocks by changing the transaction isolation
(tx_isolation
) variable from the MySQL default of REPEATABLE-READ
to
READ-COMMITTED
by creating both a pre-settings.php
hook script and a
post-settings.php
hook script.
First, create a pre-settings.php
hook script containing the following
line:
$conf['acquia_hosting_settings_autoconnect'] = FALSE;
Next, download this example acsf-hook-tx-isolation.php
script to create a post-settings.php
hook script.
For more information, see Fixing database deadlocks in the Acquia Support Knowledge Base.