diff --git a/core/INSTALL.txt b/core/INSTALL.txt index c839761..26c4f51 100644 --- a/core/INSTALL.txt +++ b/core/INSTALL.txt @@ -171,36 +171,40 @@ INSTALLATION b. Missing settings file. - Drupal will try to automatically create a settings.php configuration file, - which is normally in the directory sites/default (to avoid problems when - upgrading, Drupal is not packaged with this file). If auto-creation fails, - you will need to create this file yourself, using the file - sites/default/default.settings.php as a template. + Drupal will try to automatically create settings.php and services.yml + files, which are normally in the directory settings (to avoid + problems when upgrading, Drupal is not packaged with this file). If + auto-creation of either file fails, you will need to create the file + yourself. Use the template core/default.settings.php or + core/default.services.yml respectively. For example, on a Unix/Linux command line, you can make a copy of the default.settings.php file with the command: - cp sites/default/default.settings.php sites/default/settings.php + cp core/default.settings.php settings/settings.php + cp core/default.services.yml settings/services.yml Next, grant write privileges to the file to everyone (including the web server) with the command: - chmod a+w sites/default/settings.php + chmod a+w settings/settings.php + chmod a+w settings/services.yml Be sure to set the permissions back after the installation is finished! Sample command: - chmod go-w sites/default/settings.php + chmod go-w settings/settings.php + chmod go-w settings/services.yml c. Write permissions after install. - The install script will attempt to write-protect the settings.php file and - the sites/default directory after saving your configuration. If this - fails, you will be notified, and you can do it manually. Sample commands - from a Unix/Linux command line: + The install script will attempt to write-protect the settings.php file + after saving your configuration. If this fails, you will be notified, and + you can do it manually. Sample commands from a Unix/Linux command line: - chmod go-w sites/default/settings.php - chmod go-w sites/default + chmod go-w settings/settings.php + chmod go-w settings/services.yml + chmod go-w settings 4. Verify that the site is working. @@ -325,9 +329,9 @@ Drupal can be reinstalled without downloading and extracting the Drupal release. 1. Drop all the tables in your database. -2. Remove everything in sites/default/files. +2. Remove everything in the files directory. -3. Remove sites/default/settings.php. +3. Remove settings.php. 4. Follow the Installation Instructions above starting from Step 3 (Run the install script). @@ -361,28 +365,28 @@ MULTISITE CONFIGURATION A single Drupal installation can host several Drupal-powered sites, each with its own individual configuration. -For this to work you need the file sites/sites.php to exist. Make a copy of -the example.sites.php file: +For this to work you need to enable the commented out $sites variable in the +settings.php in Drupal's root directory, like so: - $ cp sites/example.sites.php sites/sites.php + $sites = array(); Additional site configurations are created in subdirectories within the 'sites' directory. Each subdirectory must have a 'settings.php' file, which specifies the configuration settings. The easiest way to create additional sites is to -copy file 'default.settings.php' from the 'sites/default' directory into the -new site directory with file name 'settings.php' and modify as appropriate. +copy file 'core/default.settings.php' into the new site directory with file name +'settings.php' and modify as appropriate. + The new directory name is constructed from the site's URL. The configuration for www.example.com could be in 'sites/example.com/settings.php' (note that 'www.' should be omitted if users can access your site at http://example.com/). - $ cp sites/default/defaults.settings.php sites/example.com/settings.php + $ cp core/default.settings.php sites/example.com/settings.php Sites do not have to have a different domain. You can also use subdomains and subdirectories for Drupal sites. For example, example.com, sub.example.com, and sub.example.com/site3 can all be defined as independent Drupal sites. The setup for a configuration such as this would look like the following: - sites/default/settings.php sites/example.com/settings.php sites/sub.example.com/settings.php sites/sub.example.com.site3/settings.php @@ -397,7 +401,7 @@ first configuration it finds: sites/www.sub.example.com/settings.php sites/sub.example.com/settings.php sites/example.com/settings.php - sites/default/settings.php + settings.php If you are installing on a non-standard port, the port number is treated as the deepest subdomain. For example: http://www.example.com:8080/ could be loaded diff --git a/core/UPGRADE.txt b/core/UPGRADE.txt new file mode 100644 index 0000000..a422639 --- /dev/null +++ b/core/UPGRADE.txt @@ -0,0 +1,130 @@ +INTRODUCTION +------------ +This document describes how to: + + * Update your Drupal site from one minor 8.x version to another minor 8.x + version; for example, from 8.8 to 8.9, or from 8.6 to 8.10. + + * Migrate your Drupal site to version 8.x. + +First steps and definitions: + + * If you are upgrading to Drupal version x.y, then x is known as the major + version number, and y is known as the minor version number. The download + file will be named drupal-x.y.tar.gz (or drupal-x.y.zip). + + * All directories mentioned in this document are relative to the directory of + your Drupal installation. + + * Make a full backup of all files, directories, and your database(s) before + starting, and save it outside your Drupal installation directory. + Instructions may be found at http://drupal.org/upgrade/backing-up-the-db + + * It is wise to try an update or upgrade on a test copy of your site before + applying it to your live site. Even minor updates can cause your site's + behavior to change. + + * Each new release of Drupal has release notes, which explain the changes made + since the previous version and any special instructions needed to update or + upgrade to the new version. You can find a link to the release notes for the + version you are upgrading or updating to on the Drupal project page + (http://drupal.org/project/drupal). + +UPGRADE PROBLEMS +---------------- +If you encounter errors during this process, + + * Note any error messages you see. + + * Restore your site to its previous state, using the file and database backups + you created before you started the upgrade process. Do not attempt to do + further upgrades on a site that had update problems. + + * Consult one of the support options listed on http://drupal.org/support + +More in-depth information on upgrading can be found at http://drupal.org/upgrade + +MINOR VERSION UPDATES +--------------------- +To update from one minor 8.x version of Drupal to any later 8.x version, after +following the instructions in the INTRODUCTION section at the top of this file: + +1. Log in as a user with the permission "Administer software updates". + +2. Go to Administration > Configuration > Development > Maintenance mode. + Enable the "Put site into maintenance mode" checkbox and save the + configuration. + +3. Remove all old core files and directories, except for the 'sites' directory + and any custom files you added elsewhere. + + If you made modifications to files like .htaccess or robots.txt, you will + need to re-apply them from your backup, after the new files are in place. + + Sometimes an update includes changes to core/default.settings.php (this will + be noted in the release notes). If that's the case, follow these steps: + + - Make a backup copy of your settings.php file, with a different file name. + + - Make a copy of the new default.settings.php file, and name the copy + settings.php (overwriting your previous settings.php file). + + - Copy the custom and site-specific entries from the backup you made into the + new settings.php file. You will definitely need the lines giving the + database information, and you will also want to copy in any other + customizations you have added. + +4. Download the latest Drupal 8.x release from http://drupal.org to a + directory outside of your web root. Extract the archive and copy the files + into your Drupal directory. + + On a typical Unix/Linux command line, use the following commands to download + and extract: + + wget http://drupal.org/files/projects/drupal-x.y.tar.gz + tar -zxvf drupal-x.y.tar.gz + + This creates a new directory drupal-x.y/ containing all Drupal files and + directories. Copy the files into your Drupal installation directory: + + cp -R drupal-x.y/* drupal-x.y/.htaccess /path/to/your/installation + + If you do not have command line access to your server, download the archive + from http://drupal.org using your web browser, extract it, and then use an + FTP client to upload the files to your web root. + +5. Re-apply any modifications to files such as .htaccess or robots.txt. + +6. Run update.php by visiting http://www.example.com/core/update.php (replace + www.example.com with your domain name). This will update the core database + tables. + + If you are unable to access update.php do the following: + + - Open settings.php with a text editor. + + - Find the line that says: + $settings['update_free_access'] = FALSE; + + - Change it into: + $settings['update_free_access'] = TRUE; + + - Once the upgrade is done, $settings['update_free_access'] must be + reverted to FALSE. + +7. Go to Administration > Reports > Status report. Verify that everything is + working as expected. + +8. Ensure that $settings['update_free_access'] is FALSE in settings.php. + +9. Go to Administration > Configuration > Development > Maintenance mode. + Disable the "Put site into maintenance mode" checkbox and save the + configuration. + +MAJOR VERSION MIGRATION +----------------------- +Upgrading from a prior major version of Drupal to Drupal 8.x is not possible. +The process now requires a migration to a Drupal 8.x site, utilizing the Migrate +module in Drupal core. + +Note that migration support in Drupal 8 is currently only partially implemented. diff --git a/core/default.services.yml b/core/default.services.yml new file mode 100644 index 0000000..280eb43 --- /dev/null +++ b/core/default.services.yml @@ -0,0 +1,53 @@ +parameters: + twig.config: + # Twig debugging: + # + # When debugging is enabled: + # - The markup of each Twig template is surrounded by HTML comments that + # contain theming information, such as template file name suggestions. + # - Note that this debugging markup will cause automated tests that directly + # check rendered HTML to fail. When running automated tests, 'twig_debug' + # should be set to FALSE. + # - The dump() function can be used in Twig templates to output information + # about template variables. + # - Twig templates are automatically recompiled whenever the source code + # changes (see twig_auto_reload below). + # + # For more information about debugging Twig templates, see + # http://drupal.org/node/1906392. + # + # Not recommended in production environments + # @default false + debug: false + # Twig auto-reload: + # + # Automatically recompile Twig templates whenever the source code changes. + # If you don't provide a value for twig_auto_reload, it will be determined + # based on the value of twig_debug. + # + # Not recommended in production environments + # @default null + auto_reload: null + # Twig cache: + # + # By default, Twig templates will be compiled and stored in the filesystem + # to increase performance. Disabling the Twig cache will recompile the + # templates from source each time they are used. In most cases the + # twig_auto_reload setting above should be enabled rather than disabling the + # Twig cache. + # + # Not recommended in production environments + # @default true + cache: true + factory.keyvalue: + {} + # Default key/value storage service to use. + # @default keyvalue.database + #default: keyvalue.database + # Collection-specific overrides. + #state: keyvalue.database + factory.keyvalue.expirable: + {} + # Default key/value expirable storage service to use. + # @default keyvalue.database.expirable + #default: keyvalue.database.expirable diff --git a/core/default.settings.php b/core/default.settings.php new file mode 100644 index 0000000..3936dcb --- /dev/null +++ b/core/default.settings.php @@ -0,0 +1,641 @@ + 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'port' => 3306, + * 'prefix' => 'myprefix_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * The "driver" property indicates what Drupal database driver the + * connection should use. This is usually the same as the name of the + * database type, such as mysql or sqlite, but not always. The other + * properties will vary depending on the driver. For SQLite, you must + * specify a database file name in a directory that is writable by the + * webserver. For most other drivers, you must specify a + * username, password, host, and database name. + * + * Transaction support is enabled by default for all drivers that support it, + * including MySQL. To explicitly disable it, set the 'transactions' key to + * FALSE. + * Note that some configurations of MySQL, such as the MyISAM engine, don't + * support it and will proceed silently even if enabled. If you experience + * transaction related crashes with such configuration, set the 'transactions' + * key to FALSE. + * + * For each database, you may optionally specify multiple "target" databases. + * A target database allows Drupal to try to send certain queries to a + * different database if it can but fall back to the default connection if not. + * That is useful for primary/replica replication, as Drupal may try to connect + * to a replica server when appropriate and if one is not available will simply + * fall back to the single primary server (The terms primary/replica are + * traditionally referred to as master/slave in database server documentation). + * + * The general format for the $databases array is as follows: + * @code + * $databases['default']['default'] = $info_array; + * $databases['default']['replica'][] = $info_array; + * $databases['default']['replica'][] = $info_array; + * $databases['extra']['default'] = $info_array; + * @endcode + * + * In the above example, $info_array is an array of settings described above. + * The first line sets a "default" database that has one primary database + * (the second level default). The second and third lines create an array + * of potential replica databases. Drupal will select one at random for a given + * request as needed. The fourth line creates a new database with a name of + * "extra". + * + * For a single database configuration, the following is sufficient: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => 'main_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * You can optionally set prefixes for some or all database table names + * by using the 'prefix' setting. If a prefix is specified, the table + * name will be prepended with its value. Be sure to use valid database + * characters only, usually alphanumeric and underscore. If no prefixes + * are desired, leave it as an empty string ''. + * + * To have all database names prefixed, set 'prefix' as a string: + * @code + * 'prefix' => 'main_', + * @endcode + * To provide prefixes for specific tables, set 'prefix' as an array. + * The array's keys are the table names and the values are the prefixes. + * The 'default' element is mandatory and holds the prefix for any tables + * not specified elsewhere in the array. Example: + * @code + * 'prefix' => array( + * 'default' => 'main_', + * 'users' => 'shared_', + * 'sessions' => 'shared_', + * 'role' => 'shared_', + * 'authmap' => 'shared_', + * ), + * @endcode + * You can also use a reference to a schema/database as a prefix. This may be + * useful if your Drupal installation exists in a schema that is not the default + * or you want to access several databases from the same code base at the same + * time. + * Example: + * @code + * 'prefix' => array( + * 'default' => 'main.', + * 'users' => 'shared.', + * 'sessions' => 'shared.', + * 'role' => 'shared.', + * 'authmap' => 'shared.', + * ); + * @endcode + * NOTE: MySQL and SQLite's definition of a schema is a database. + * + * Advanced users can add or override initial commands to execute when + * connecting to the database server, as well as PDO connection settings. For + * example, to enable MySQL SELECT queries to exceed the max_join_size system + * variable, and to reduce the database connection timeout to 5 seconds: + * + * @code + * $databases['default']['default'] = array( + * 'init_commands' => array( + * 'big_selects' => 'SET SQL_BIG_SELECTS=1', + * ), + * 'pdo' => array( + * PDO::ATTR_TIMEOUT => 5, + * ), + * ); + * @endcode + * + * WARNING: These defaults are designed for database portability. Changing them + * may cause unexpected behavior, including potential data loss. + * + * @see DatabaseConnection_mysql::__construct + * @see DatabaseConnection_pgsql::__construct + * @see DatabaseConnection_sqlite::__construct + * + * Database configuration format: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'pgsql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'sqlite', + * 'database' => '/path/to/databasefilename', + * ); + * @endcode + */ +$databases = array(); + +/** + * Location of the site configuration files. + * + * The $config_directories array specifies the location of file system + * directories used for configuration data. On install, "active" and "staging" + * directories are created for configuration. The staging directory is used for + * configuration imports; the active directory is not used by default, since the + * default storage for active configuration is the database rather than the file + * system (this can be changed; see "Active configuration settings" below). + * + * The default location for the active and staging directories is inside a + * randomly-named directory in the public files path; this setting allows you to + * override these locations. If you use files for the active configuration, you + * can enhance security by putting the active configuration outside your + * document root. + * + * Example: + * @code + * $config_directories = array( + * CONFIG_ACTIVE_DIRECTORY => '/some/directory/outside/webroot', + * CONFIG_STAGING_DIRECTORY => '/another/directory/outside/webroot', + * ); + * @endcode + */ +$config_directories = array(); + +/** + * Settings: + * + * $settings contains environment-specific configuration, such as the files + * directory and reverse proxy address, and temporary configuration, such as + * turning on Twig debugging and security overrides. + * + * @see \Drupal\Core\Site\Settings::get() + */ + +/** + * Salt for one-time login links, cancel links, form tokens, etc. + * + * This variable will be set to a random value by the installer. All one-time + * login links will be invalidated if the value is changed. Note that if your + * site is deployed on a cluster of web servers, you must ensure that this + * variable has the same value on each server. + * + * For enhanced security, you may set this variable to the contents of a file + * outside your document root; you should also ensure that this file is not + * stored with backups of your database. + * + * Example: + * @code + * $settings['hash_salt'] = file_get_contents('/home/example/salt.txt'); + * @endcode + */ +$settings['hash_salt'] = ''; + +/** + * Access control for update.php script. + * + * If you are updating your Drupal installation using the update.php script but + * are not logged in using either an account with the "Administer software + * updates" permission or the site maintenance account (the account that was + * created during installation), you will need to modify the access check + * statement below. Change the FALSE to a TRUE to disable the access check. + * After finishing the upgrade, be sure to open this file again and change the + * TRUE back to a FALSE! + */ +$settings['update_free_access'] = FALSE; + +/** + * External access proxy settings: + * + * If your site must access the Internet via a web proxy then you can enter + * the proxy settings here. Currently only basic authentication is supported + * by using the username and password variables. The proxy_user_agent variable + * can be set to NULL for proxies that require no User-Agent header or to a + * non-empty string for proxies that limit requests to a specific agent. The + * proxy_exceptions variable is an array of host names to be accessed directly, + * not via proxy. + */ +# $settings['proxy_server'] = ''; +# $settings['proxy_port'] = 8080; +# $settings['proxy_username'] = ''; +# $settings['proxy_password'] = ''; +# $settings['proxy_user_agent'] = ''; +# $settings['proxy_exceptions'] = array('127.0.0.1', 'localhost'); + +/** + * Reverse Proxy Configuration: + * + * Reverse proxy servers are often used to enhance the performance + * of heavily visited sites and may also provide other site caching, + * security, or encryption benefits. In an environment where Drupal + * is behind a reverse proxy, the real IP address of the client should + * be determined such that the correct client IP address is available + * to Drupal's logging, statistics, and access management systems. In + * the most simple scenario, the proxy server will add an + * X-Forwarded-For header to the request that contains the client IP + * address. However, HTTP headers are vulnerable to spoofing, where a + * malicious client could bypass restrictions by setting the + * X-Forwarded-For header directly. Therefore, Drupal's proxy + * configuration requires the IP addresses of all remote proxies to be + * specified in $settings['reverse_proxy_addresses'] to work correctly. + * + * Enable this setting to get Drupal to determine the client IP from + * the X-Forwarded-For header (or $settings['reverse_proxy_header'] if set). + * If you are unsure about this setting, do not have a reverse proxy, + * or Drupal operates in a shared hosting environment, this setting + * should remain commented out. + * + * In order for this setting to be used you must specify every possible + * reverse proxy IP address in $settings['reverse_proxy_addresses']. + * If a complete list of reverse proxies is not available in your + * environment (for example, if you use a CDN) you may set the + * $_SERVER['REMOTE_ADDR'] variable directly in settings.php. + * Be aware, however, that it is likely that this would allow IP + * address spoofing unless more advanced precautions are taken. + */ +# $settings['reverse_proxy'] = TRUE; + +/** + * Specify every reverse proxy IP address in your environment. + * This setting is required if $settings['reverse_proxy'] is TRUE. + */ +# $settings['reverse_proxy_addresses'] = array('a.b.c.d', ...); + +/** + * Set this value if your proxy server sends the client IP in a header + * other than X-Forwarded-For. + */ +# $settings['reverse_proxy_header'] = 'HTTP_X_CLUSTER_CLIENT_IP'; + +/** + * Page caching: + * + * By default, Drupal sends a "Vary: Cookie" HTTP header for anonymous page + * views. This tells a HTTP proxy that it may return a page from its local + * cache without contacting the web server, if the user sends the same Cookie + * header as the user who originally requested the cached page. Without "Vary: + * Cookie", authenticated users would also be served the anonymous page from + * the cache. If the site has mostly anonymous users except a few known + * editors/administrators, the Vary header can be omitted. This allows for + * better caching in HTTP proxies (including reverse proxies), i.e. even if + * clients send different cookies, they still get content served from the cache. + * However, authenticated users should access the site directly (i.e. not use an + * HTTP proxy, and bypass the reverse proxy if one is used) in order to avoid + * getting cached pages from the proxy. + */ +# $settings['omit_vary_cookie'] = TRUE; + +/** + * Class Loader. + * + * By default, Composer's ClassLoader is used, which is best for development, as + * it does not break when code is moved in the file system. You can decorate the + * class loader with a cached solution for better performance, which is + * recommended for production sites. + * + * To do so, you may decorate and replace the local $class_loader variable. + * + * For example, to use Symfony's APC class loader, uncomment the code below. + */ +/* +if ($settings['hash_salt']) { + $apc_loader = new \Symfony\Component\ClassLoader\ApcClassLoader('drupal.' . $settings['hash_salt'], $class_loader); + $class_loader->unregister(); + $apc_loader->register(); + $class_loader = $apc_loader; +} +*/ + +/** + * Authorized file system operations: + * + * The Update Manager module included with Drupal provides a mechanism for + * site administrators to securely install missing updates for the site + * directly through the web user interface. On securely-configured servers, + * the Update manager will require the administrator to provide SSH or FTP + * credentials before allowing the installation to proceed; this allows the + * site to update the new files as the user who owns all the Drupal files, + * instead of as the user the webserver is running as. On servers where the + * webserver user is itself the owner of the Drupal files, the administrator + * will not be prompted for SSH or FTP credentials (note that these server + * setups are common on shared hosting, but are inherently insecure). + * + * Some sites might wish to disable the above functionality, and only update + * the code directly via SSH or FTP themselves. This setting completely + * disables all functionality related to these authorized file operations. + * + * @see http://drupal.org/node/244924 + * + * Remove the leading hash signs to disable. + */ +# $settings['allow_authorize_operations'] = FALSE; + +/** + * Mixed-mode sessions: + * + * Set to TRUE to create both secure and insecure sessions when using HTTPS. + * Defaults to FALSE. + */ +# $settings['mixed_mode_sessions'] = TRUE; + +/** + * Default mode for for directories and files written by Drupal. + * + * Value should be in PHP Octal Notation, with leading zero. + */ +# $settings['file_chmod_directory'] = 0775; +# $settings['file_chmod_file'] = 0664; + +/** + * Public file path: + * + * A local file system path where public files will be stored. This directory + * must exist and be writable by Drupal. This directory must be relative to + * the Drupal installation directory and be accessible over the web. + */ +# $settings['file_public_path'] = 'sites/default/files'; + +/** + * Session write interval: + * + * Set the minimum interval between each session write to database. + * For performance reasons it defaults to 180. + */ +# $settings['session_write_interval'] = 180; + +/** + * String overrides: + * + * To override specific strings on your site with or without enabling the Locale + * module, add an entry to this list. This functionality allows you to change + * a small number of your site's default English language interface strings. + * + * Remove the leading hash signs to enable. + * + * The "en" part of the variable name, is dynamic and can be any langcode of + * any added language. (eg locale_custom_strings_de for german). + */ +# $settings['locale_custom_strings_en'][''] = array( +# 'forum' => 'Discussion board', +# '@count min' => '@count minutes', +# ); + +/** + * A custom theme for the offline page: + * + * This applies when the site is explicitly set to maintenance mode through the + * administration page or when the database is inactive due to an error. + * The template file should also be copied into the theme. It is located inside + * 'core/modules/system/templates/maintenance-page.html.twig'. + * + * Note: This setting does not apply to installation and update pages. + */ +# $settings['maintenance_theme'] = 'bartik'; + +/** + * Base URL (optional). + * + * If Drupal is generating incorrect URLs on your site, which could + * be in HTML headers (links to CSS and JS files) or visible links on pages + * (such as in menus), uncomment the Base URL statement below (remove the + * leading hash sign) and fill in the absolute URL to your Drupal installation. + * + * You might also want to force users to use a given domain. + * See the .htaccess file for more information. + * + * Examples: + * $base_url = 'http://www.example.com'; + * $base_url = 'http://www.example.com:8888'; + * $base_url = 'http://www.example.com/drupal'; + * $base_url = 'https://www.example.com:8888/drupal'; + * + * It is not allowed to have a trailing slash; Drupal will add it + * for you. + */ +# $base_url = 'http://www.example.com'; // NO trailing slash! + +/** + * PHP settings: + * + * To see what PHP settings are possible, including whether they can be set at + * runtime (by using ini_set()), read the PHP documentation: + * http://php.net/manual/ini.list.php + * See \Drupal\Core\DrupalKernel::bootEnvironment() for required runtime + * settings and the .htaccess file for non-runtime settings. + * Settings defined there should not be duplicated here so as to avoid conflict + * issues. + */ + +/** + * Some distributions of Linux (most notably Debian) ship their PHP + * installations with garbage collection (gc) disabled. Since Drupal depends on + * PHP's garbage collection for clearing sessions, ensure that garbage + * collection occurs by using the most common settings. + */ +ini_set('session.gc_probability', 1); +ini_set('session.gc_divisor', 100); + +/** + * Set session lifetime (in seconds), i.e. the time from the user's last visit + * to the active session may be deleted by the session garbage collector. When + * a session is deleted, authenticated users are logged out, and the contents + * of the user's $_SESSION variable is discarded. + */ +ini_set('session.gc_maxlifetime', 200000); + +/** + * Set session cookie lifetime (in seconds), i.e. the time from the session is + * created to the cookie expires, i.e. when the browser is expected to discard + * the cookie. The value 0 means "until the browser is closed". + */ +ini_set('session.cookie_lifetime', 2000000); + +/** + * If you encounter a situation where users post a large amount of text, and + * the result is stripped out upon viewing but can still be edited, Drupal's + * output filter may not have sufficient memory to process it. If you + * experience this issue, you may wish to uncomment the following two lines + * and increase the limits of these variables. For more information, see + * http://php.net/manual/pcre.configuration.php. + */ +# ini_set('pcre.backtrack_limit', 200000); +# ini_set('pcre.recursion_limit', 200000); + +/** + * Drupal automatically generates a unique session cookie name for each site + * based on its full domain name. If you have multiple domains pointing at the + * same Drupal site, you can either redirect them all to a single domain (see + * comment in .htaccess), or uncomment the line below and specify their shared + * base domain. Doing so assures that users remain logged in as they cross + * between your various domains. Make sure to always start the $cookie_domain + * with a leading dot, as per RFC 2109. + */ +# $cookie_domain = '.example.com'; + +/** + * Active configuration settings. + * + * By default, the active configuration is stored in the database in the + * {config} table. To use a different storage mechanism for the active + * configuration, do the following prior to installing: + * - Override the 'bootstrap_config_storage' setting here. It must be set to a + * callable that returns an object that implements + * \Drupal\Core\Config\StorageInterface. + * - Override the service definition 'config.storage.active'. Put this + * override in a services.yml file in the same directory as settings.php + * (definitions in this file will override service definition defaults). + */ +# $settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage'); + +/** + * Configuration overrides. + * + * To globally override specific configuration values for this site, + * set them here. You usually don't need to use this feature. This is + * useful in a configuration file for a vhost or directory, rather than + * the default settings.php. + * + * Note that any values you provide in these variable overrides will not be + * modifiable from the Drupal administration interface. + */ +# $config['system.site']['name'] = 'My Drupal site'; +# $config['system.theme']['default'] = 'stark'; +# $config['user.settings']['anonymous'] = 'Visitor'; + +/** + * CSS/JS aggregated file gzip compression: + * + * By default, when CSS or JS aggregation and clean URLs are enabled Drupal will + * store a gzip compressed (.gz) copy of the aggregated files. If this file is + * available then rewrite rules in the default .htaccess file will serve these + * files to browsers that accept gzip encoded content. This allows pages to load + * faster for these users and has minimal impact on server load. If you are + * using a webserver other than Apache httpd, or a caching reverse proxy that is + * configured to cache and compress these files itself you may want to uncomment + * one or both of the below lines, which will prevent gzip files being stored. + */ +# $config['system.performance']['css']['gzip'] = FALSE; +# $config['system.performance']['js']['gzip'] = FALSE; + +/** + * Fast 404 pages: + * + * Drupal can generate fully themed 404 pages. However, some of these responses + * are for images or other resource files that are not displayed to the user. + * This can waste bandwidth, and also generate server load. + * + * The options below return a simple, fast 404 page for URLs matching a + * specific pattern: + * - $conf['system.performance]['fast_404']['exclude_paths']: A regular + * expression to match paths to exclude, such as images generated by image + * styles, or dynamically-resized images. If you need to add more paths, you + * can add '|path' to the expression. + * - $conf['system.performance]['fast_404']['paths']: A regular expression to + * match paths that should return a simple 404 page, rather than the fully + * themed 404 page. If you don't have any aliases ending in htm or html you + * can add '|s?html?' to the expression. + * - $conf['system.performance]['fast_404']['html']: The html to return for + * simple 404 pages. + * + * Remove the leading hash signs if you would like to alter this functionality. + */ +# $config['system.performance']['fast_404']['exclude_paths'] = '/\/(?:styles)\//'; +# $config['system.performance']['fast_404']['paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; +# $config['system.performance']['fast_404']['html'] = '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

'; + +/** + * Load local development override configuration, if available. + * + * Use settings.local.php to override variables on secondary (staging, + * development, etc) installations of this site. Typically used to disable + * caching, JavaScript/CSS compression, re-routing of outgoing emails, and + * other things that should not happen on development and testing sites. + * + * Keep this code block at the end of this file to take full effect. + */ +# if (file_exists(__DIR__ . '/settings.local.php')) { +# include __DIR__ . '/settings.local.php'; +# } diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 292e918..4374728 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -13,6 +13,7 @@ use Drupal\Component\Render\MarkupInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Site\Settings; +use Drupal\Core\Site\Site; use Drupal\Core\Utility\Error; use Drupal\Core\StringTranslation\TranslatableMarkup; @@ -128,6 +129,26 @@ define('DRUPAL_ROOT', dirname(dirname(__DIR__))); /** + * Returns the appropriate configuration directory. + * + * Temporary backwards-compatibility layer for Drush. + * + * @deprecated 8.x-dev + * Use \Drupal\Core\Site\Site::getPath() instead. + * + * @internal + */ +function conf_path() { + if (strpos(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)[1]['function'], 'drush') === FALSE) { + throw new \Exception('conf_path() is retained for Drush compatibility only.'); + } + // When called from _drush_bootstrap_drupal_site_validate() on testbots, this + // function is supposed to return the site path of the parent site, which is + // '' (the document root). Ensure that the returned path is relative. + // @see https://github.com/drush-ops/drush/blob/master/includes/bootstrap.inc#L782 + return '.'; +} +/** * Returns the path of a configuration directory. * * Configuration directories are configured using $config_directories in diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index ceb9982..a5e9e44 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -18,6 +18,7 @@ use Drupal\Core\Language\LanguageManager; use Drupal\Core\Logger\LoggerChannelFactory; use Drupal\Core\Site\Settings; +use Drupal\Core\Site\Site; use Drupal\Core\StringTranslation\Translator\FileTranslation; use Drupal\Core\StackMiddleware\ReverseProxyMiddleware; use Drupal\Core\Extension\ExtensionDiscovery; @@ -320,6 +321,12 @@ function install_begin_request($class_loader, &$install_state) { $site_path = DrupalKernel::findSitePath($request, FALSE); Settings::initialize(dirname(dirname(__DIR__)), $site_path, $class_loader); + // Initialize the site directory. + // This primes the site path to be used during installation, to allow an empty + // site folder to be prepared in the /sites directory into which Drupal will + // be installed. + Site::initInstaller(DRUPAL_ROOT); + // Ensure that procedural dependencies are loaded as early as possible, // since the error/exception handlers depend on them. require_once __DIR__ . '/../modules/system/system.install'; @@ -419,7 +426,7 @@ function install_begin_request($class_loader, &$install_state) { $directory = $GLOBALS['config']['locale.settings']['translation']['path']; } else { - $directory = $site_path . '/files/translations'; + $directory = Site::getPath('files/translations'); } $container->set('string_translator.file_translation', new FileTranslation($directory)); $container->get('string_translation') @@ -1097,8 +1104,7 @@ function install_verify_completed_task() { function install_verify_database_settings($site_path) { if ($database = Database::getConnectionInfo()) { $database = $database['default']; - $settings_file = './' . $site_path . '/settings.php'; - $errors = install_database_errors($database, $settings_file); + $errors = install_database_errors($database); if (empty($errors)) { return TRUE; } @@ -1124,14 +1130,19 @@ function install_verify_database_ready() { /** * Checks a database connection and returns any errors. */ -function install_database_errors($database, $settings_file) { + +function install_database_errors($database) { $errors = array(); // Check database type. $database_types = drupal_get_database_types(); $driver = $database['driver']; if (!isset($database_types[$driver])) { - $errors['driver'] = t("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", array('%settings_file' => $settings_file, '@drupal' => drupal_install_profile_distribution_name(), '%driver' => $driver)); + $errors['driver'] = t("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", array( + '%settings_file' => Site::getPath('settings.php'), + '@drupal' => drupal_install_profile_distribution_name(), + '%driver' => $driver, + )); } else { // Run driver specific validation @@ -1804,9 +1815,8 @@ function install_check_translations($langcode, $server_pattern) { $readable = FALSE; $writable = FALSE; // @todo: Make this configurable. - $site_path = \Drupal::service('site.path'); - $files_directory = $site_path . '/files'; - $translations_directory = $site_path . '/files/translations'; + $files_directory = Site::getPath('files'); + $translations_directory = Site::getPath('files/translations'); $translations_directory_exists = FALSE; $online = FALSE; @@ -1971,8 +1981,9 @@ function install_check_requirements($install_state) { $readable = FALSE; $writable = FALSE; $site_path = './' . \Drupal::service('site.path'); - $file = $site_path . "/{$default_file_info['file']}"; - $default_file = "./sites/default/{$default_file_info['file_default']}"; + $conf_path = './' . conf_path(FALSE); + $file = $conf_path . "/{$default_file_info['file']}"; + $default_file = "./core/{$default_file_info['file_default']}"; $exists = FALSE; // Verify that the directory exists. if (drupal_verify_install_file($site_path, FILE_EXIST, 'dir')) { diff --git a/core/includes/install.inc b/core/includes/install.inc index 3a9c2bc..1a11920 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -12,6 +12,7 @@ use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\Core\Site\Settings; +use Drupal\Core\Site\Site; /** * Requirement severity -- Informational message only. @@ -215,7 +216,7 @@ function drupal_get_database_types() { */ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { if (!isset($settings_file)) { - $settings_file = \Drupal::service('site.path') . '/settings.php'; + $settings_file = Site::getPath('settings.php'); } // Build list of setting names and insert the values into the global namespace. $variable_names = array(); @@ -646,6 +647,9 @@ function drupal_install_system($install_state) { * * @return * TRUE on success or FALSE on failure. A message is set for the latter. + * + * @todo Do not automatically call into drupal_install_fix_file(). + * @see https://drupal.org/node/1616266 */ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') { $return = TRUE; diff --git a/core/includes/update.inc b/core/includes/update.inc index 213d15d..452c1ab 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -9,6 +9,12 @@ */ use Drupal\Component\Graph\Graph; +use Drupal\Component\Utility\String; +use Drupal\Core\Config\FileStorage; +use Drupal\Core\Config\ConfigException; +use Drupal\Core\DrupalKernel; +use Drupal\Core\Page\DefaultHtmlPageRenderer; +use Drupal\Core\Site\Site; use Drupal\Core\Utility\Error; /** @@ -62,6 +68,34 @@ function update_check_incompatibility($name, $type = 'module') { } /** + * Returns whether the settings file requirement has been satisfied. + * + * @return array + * A requirements info array. + */ +function update_settings_file_requirements() { + $requirements = array(); + + // Check whether settings.php needs to be rewritten. + $settings_file = Site::getPath('settings.php'); + $writable = drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_WRITABLE); + $requirements['settings file']['title'] = 'Settings file'; + if ($writable) { + $requirements['settings file'] += array( + 'value' => 'settings.php is writable.', + ); + } + else { + $requirements['settings file'] += array( + 'value' => 'settings.php is not writable.', + 'severity' => REQUIREMENT_ERROR, + 'description' => 'Drupal requires write permissions to ' . $settings_file . ' during the update process. If you are unsure how to grant file permissions, consult the online handbook.', + ); + } + return $requirements; +} + +/** * Returns whether the minimum schema requirement has been satisfied. * * @return array diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php index f56b26c..dbae423 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php @@ -6,6 +6,7 @@ use Drupal\Core\Database\Driver\sqlite\Connection; use Drupal\Core\Database\DatabaseNotFoundException; use Drupal\Core\Database\Install\Tasks as InstallTasks; +use Drupal\Core\Site\Site; /** * Specifies installation tasks for SQLite databases. diff --git a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php index 6d5fe65..59f7fec 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php @@ -6,6 +6,7 @@ use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Locale\CountryManagerInterface; +use Drupal\Core\Site\Site; use Drupal\Core\State\StateInterface; use Drupal\user\UserStorageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -123,6 +124,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { // Warn about settings.php permissions risk $settings_dir = $this->sitePath; $settings_file = $settings_dir . '/settings.php'; + // Check that $_POST is empty so we only show this message when the form is // first displayed, not on the next page after it is submitted. (We do not // want to repeat it multiple times because it is a general warning that is diff --git a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php index f5d1c7f..93ad8a1 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php @@ -139,7 +139,6 @@ public function buildForm(array $form, FormStateInterface $form_state) { ); $form['errors'] = array(); - $form['settings_file'] = array('#type' => 'value', '#value' => $settings_file); return $form; } diff --git a/core/lib/Drupal/Core/Site/Settings.php b/core/lib/Drupal/Core/Site/Settings.php index 39a7e5a..1998aeb 100644 --- a/core/lib/Drupal/Core/Site/Settings.php +++ b/core/lib/Drupal/Core/Site/Settings.php @@ -112,8 +112,24 @@ public static function initialize($app_root, $site_path, &$class_loader) { $config = array(); $databases = array(); - if (is_readable($app_root . '/' . $site_path . '/settings.php')) { - require $app_root . '/' . $site_path . '/settings.php'; + // Read the global /settings/settings.php file. + // Allow it to set/override the following variables: + $sites = NULL; + $conf_path = NULL; + // Exclude it for test requests to prevent settings of the test runner from + // leaking into the test environment. + if (!drupal_valid_test_ua() && is_readable(DRUPAL_ROOT . '/settings/settings.php')) { + require DRUPAL_ROOT . '/settings/settings.php'; + } + + // Discover the site directory. + Site::init(DRUPAL_ROOT, $sites, $conf_path); + + // Read settings.php of the actual site, unless it is the root/default site. + // Concatenation is safe here, since $conf_path is known to be not empty. + $conf_path = Site::getPath(); + if ($conf_path !== '' && is_readable(DRUPAL_ROOT . '/' . $conf_path . '/settings.php')) { + require DRUPAL_ROOT . '/' . $conf_path . '/settings.php'; } // Initialize Database. diff --git a/core/lib/Drupal/Core/Site/Site.php b/core/lib/Drupal/Core/Site/Site.php new file mode 100644 index 0000000..916abd9 --- /dev/null +++ b/core/lib/Drupal/Core/Site/Site.php @@ -0,0 +1,378 @@ +isInstaller()) { + throw new \BadMethodCallException('Site path is initialized already.'); + } + } + else { + new self($root_directory); + } + self::$instance->initializePath($sites, $custom_path); + + // Prevent this method from being called more than once. + if (self::$instance->isInstaller()) { + self::$instance->isInstaller = FALSE; + } + } + + /** + * Initializes the Site singleton in the early installer environment. + * + * Primes the Site singleton with an installer flag, which allows the + * application to be installed into a new and empty site directory, which does + * not contain a settings.php yet. + * + * @param string $root_directory + * The root directory to use for absolute paths; i.e., DRUPAL_ROOT. + * + * @throws \BadMethodCallException + * If the site path is initialized already. + * + * @see install_begin_request() + */ + public static function initInstaller($root_directory) { + if (isset(self::$instance)) { + throw new \BadMethodCallException('Site path is initialized already.'); + } + new self($root_directory); + // Denote that we are operating in the special installer environment. + self::$instance->isInstaller = TRUE; + } + + /** + * Constructs the Site singleton. + * + * @throws \BadMethodCallException + * If the site path is initialized already. + */ + private function __construct($root_directory) { + if (isset(self::$instance)) { + throw new \BadMethodCallException('Site path is initialized already.'); + } + $this->root = $root_directory; + self::$instance = $this; + } + + /** + * Re-initializes (resets) the Site singleton for a test run. + * + * @throws \RuntimeException + * If the site path of the test runner is not initialized yet. + * + * @throws \BadMethodCallException + * If no test is executed currently. + * + * @see \Drupal\simpletest\TestBase::prepareEnvironment() + */ + public static function setUpTest() { + if (!isset(self::$instance)) { + throw new \RuntimeException('No original Site to backup. Missing invocation of Site::init()?'); + } + if (!drupal_valid_test_ua()) { + throw new \BadMethodCallException('Site is not executing a test.'); + } + self::$original = clone self::$instance; + self::$instance = NULL; + } + + /** + * Reverts the Site singleton to the original after a test run. + * + * @throws \RuntimeException + * If there is no test runner site path to revert to. + * + * @throws \BadMethodCallException + * If a test is still being executed currently. + * + * @see \Drupal\simpletest\TestBase::restoreEnvironment() + */ + public static function tearDownTest() { + if (!isset(self::$original)) { + throw new \RuntimeException('No original Site to revert to. Missing invocation of Site::setUpTest()?'); + } + // Do not allow to restore original Site singleton in a test environment, + // unless we are testing the test environment setup and teardown itself. + // @see \Drupal\simpletest\Tests\BrokenSetUpTest + if (drupal_valid_test_ua() && !DRUPAL_TEST_IN_CHILD_SITE) { + throw new \BadMethodCallException('Unable to revert Site: A test is still being executed.'); + } + self::$instance = clone self::$original; + self::$original = NULL; + } + + /** + * Returns whether the Site singleton was instantiated for the installer. + * + * @return bool + */ + private function isInstaller() { + return $this->isInstaller; + } + + /** + * Initializes the site path. + * + * @param array|null $sites + * (optional) A multi-site mapping, as defined in settings.php. + * @param string|null $custom_path + * (optional) An explicit site path to set; skipping site negotiation. + */ + private function initializePath(array $sites = NULL, $custom_path = NULL) { + // Force-override the site directory in tests. + if ($test_prefix = drupal_valid_test_ua()) { + $this->path = 'sites/simpletest/' . substr($test_prefix, 10); + } + // An explicitly defined $conf_path in /settings.php takes precedence. + elseif (isset($custom_path)) { + $this->path = $custom_path; + } + // If the multi-site functionality was enabled in /settings.php, discover + // the path for the current site. + // $sites just needs to be defined; an explicit mapping is not required. + elseif (isset($sites)) { + $this->path = $this->determinePath($sites, !$this->isInstaller()); + } + // Otherwise, the Drupal root directory is the site directory. + else { + $this->path = ''; + } + } + + /** + * Finds the appropriate configuration directory for a given host and path. + * + * Finds a matching configuration directory file by stripping the server + * hostname from left to right and pathname from right to left. + * + * By default, the site directory must contain a 'settings.php' file. If the + * parameter $require_settings is set to FALSE, then a site directory without + * a 'settings.php' file will be valid, too. The first valid site directory + * found will be used and less specific options will be ignored. + * + * The $sites variable can define site directory aliases as an associative + * array. For example, to create a directory alias for + * http://www.drupal.org:8080/mysite/test whose configuration file is in + * sites/example.com, the array should be defined as: + * + * @code + * $sites['8080.www.drupal.org.mysite.test'] = 'example.com'; + * @endcode + * + * @see default.settings.php + * + * @param array $sites + * A multi-site alias mapping, as defined in settings.php. May be empty. + * @param bool $require_settings + * If TRUE, only site directories containing a settings.php file will be + * recognized. During installation, this is set to FALSE, so that Drupal can + * detect a site directory in which to create a new settings.php file. + * + * @return string + * The relative path of the site directory. May be an empty string, in case + * no site-specific directory matched, in which case the root directory is + * the site directory. + */ + private function determinePath(array $sites, $require_settings) { + // The hostname and optional port number, e.g. "www.example.com" or + // "www.example.com:8080". + $http_host = $_SERVER['HTTP_HOST']; + // The part of the URL following the hostname, including the leading slash. + $script_name = $_SERVER['SCRIPT_NAME'] ?: $_SERVER['SCRIPT_FILENAME']; + + $uri = explode('/', $script_name); + $server = explode('.', implode('.', array_reverse(explode(':', rtrim($http_host, '.'))))); + for ($i = count($uri) - 1; $i > 0; $i--) { + for ($j = count($server); $j > 0; $j--) { + $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i)); + // Check for an alias in $sites from settings.php. + if (isset($sites[$dir])) { + $dir = $sites[$dir]; + } + if ($require_settings) { + if (file_exists($this->root . '/sites/' . $dir . '/settings.php')) { + return "sites/$dir"; + } + } + elseif (file_exists($this->root . '/sites/' . $dir)) { + return "sites/$dir"; + } + } + } + return ''; + } + + /** + * Prefixes a given subpathname with the site directory, if any. + * + * Site::getPath() and this helper method only exists to ensure that a given + * subpathname does not result in an absolute filesystem path in case of a + * string concatenation like the following: + * + * @code + * // If the sire directory path is empty (root directory), then the resulting + * // filesystem path would become absolute; i.e.: "/some/file" + * unlink($site_path . '/some/file'); + * @endcode + * + * In case the PHP process has write access to the entire filesystem, such a + * file operation could succeed and potentially affect arbitrary other files + * and directories that happen to exist. That must not happen. + * + * @param string $subpathname + * The subpathname to prefix. + * + * @return string + * The prefixed subpathname. + * + * @throws \RuntimeException + * If the site path is not initialized yet. + */ + private function resolvePath($subpathname) { + // Extra safety protection in case a script somehow manages to bypass all + // other protections. + if (!isset($this->path)) { + throw new \RuntimeException('Site path is not initialized yet.'); + } + // A faulty call to Site::getPath() might include a leading slash (/), in + // which case the entire site path resolution of this function would be + // pointless, because the resulting path would still be absolute. Therefore, + // guarantee that even a bogus argument is resolved correctly. + $subpathname = ltrim($subpathname, '/'); + + if ($this->path !== '') { + if ($subpathname !== '') { + return $this->path . '/' . $subpathname; + } + return $this->path; + } + return $subpathname; + } + + /** + * Returns the given path relative to the site directory. + * + * Use this function instead of appending strings to the site path manually, + * because the site directory may be the root directory and thus a + * concatenated path would result in an absolute filesystem path. + * + * @param string $subpathname + * (optional) A relative subpathname to append to the site path. + * + * @return string + * The given $subpathname, potentially prefixed with the site path. + * + * @throws \RuntimeException + * If the site path is not initialized yet. + * + * @see \Drupal\Core\Site\Site::getAbsolutePath() + */ + public static function getPath($subpathname = '') { + return self::$instance->resolvePath($subpathname); + } + + /** + * Returns the given path relative to the site directory, as an absolute path. + * + * Use this function instead of appending strings to the site path manually, + * because the site directory may be the root directory and thus a + * concatenated path would result in an absolute filesystem path. + * + * @param string $subpathname + * (optional) A relative subpathname to append to the site path. + * + * @return string + * The given $subpathname, potentially prefixed with the site path, as an + * absolute filesystem path. + * + * @throws \RuntimeException + * If the site path is not initialized yet. + * + * @see \Drupal\Core\Site\Site::getPath() + */ + public static function getAbsolutePath($subpathname = '') { + $subpathname = self::$instance->resolvePath($subpathname); + if ($subpathname !== '') { + return self::$instance->root . '/' . $subpathname; + } + else { + return self::$instance->root; + } + } + +} diff --git a/core/modules/file/tests/file_test/src/StreamWrapper/DummyReadOnlyStreamWrapper.php b/core/modules/file/tests/file_test/src/StreamWrapper/DummyReadOnlyStreamWrapper.php index c0a7c05..3db076d 100644 --- a/core/modules/file/tests/file_test/src/StreamWrapper/DummyReadOnlyStreamWrapper.php +++ b/core/modules/file/tests/file_test/src/StreamWrapper/DummyReadOnlyStreamWrapper.php @@ -2,6 +2,7 @@ namespace Drupal\file_test\StreamWrapper; +use Drupal\Core\Site\Site; use Drupal\Core\StreamWrapper\LocalReadOnlyStream; /** diff --git a/core/modules/file/tests/file_test/src/StreamWrapper/DummyStreamWrapper.php b/core/modules/file/tests/file_test/src/StreamWrapper/DummyStreamWrapper.php index 1428300..00ac052 100644 --- a/core/modules/file/tests/file_test/src/StreamWrapper/DummyStreamWrapper.php +++ b/core/modules/file/tests/file_test/src/StreamWrapper/DummyStreamWrapper.php @@ -2,6 +2,7 @@ namespace Drupal\file_test\StreamWrapper; +use Drupal\Core\Site\Site; use Drupal\Core\StreamWrapper\LocalStream; /** diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php index 944810a..cf24451 100644 --- a/core/modules/simpletest/src/TestBase.php +++ b/core/modules/simpletest/src/TestBase.php @@ -8,6 +8,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Database\Database; use Drupal\Core\Site\Settings; +use Drupal\Core\Site\Site; use Drupal\Core\StreamWrapper\PublicStream; use Drupal\Core\Test\TestDatabase; use Drupal\Core\Utility\Error; @@ -1287,7 +1288,11 @@ private function prepareEnvironment() { // After preparing the environment and changing the database prefix, we are // in a valid test environment. + if (!is_dir(DRUPAL_ROOT . '/' . $this->siteDirectory)) { + throw new \RuntimeException("Test site directory '$this->siteDirectory' does not exist."); + } drupal_valid_test_ua($this->databasePrefix); + Site::setUpTest(); // Reset settings. new Settings(array( @@ -1401,6 +1406,11 @@ private function restoreEnvironment() { drupal_valid_test_ua(FALSE); } + Site::tearDownTest(); + + // Restore stream wrappers of the test runner. + file_get_stream_wrappers(); + // Restore original shutdown callbacks. $callbacks = &drupal_register_shutdown_function(); $callbacks = $this->originalShutdownCallbacks; diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index b0f90ed..089f3c7 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -588,7 +588,8 @@ protected function prepareSettings() { // installation. // Not using File API; a potential error must trigger a PHP warning. $directory = DRUPAL_ROOT . '/' . $this->siteDirectory; - copy(DRUPAL_ROOT . '/sites/default/default.settings.php', $directory . '/settings.php'); + copy(DRUPAL_ROOT . '/core/default.settings.php', $directory . '/settings.php'); + copy(DRUPAL_ROOT . '/core/default.services.yml', $directory . '/services.yml'); // All file system paths are created by System module during installation. // @see system_requirements() @@ -615,6 +616,9 @@ protected function prepareSettings() { 'value' => $this->originalProfile, 'required' => TRUE, ]; + // Write a new settings.php for the test site environment. + // drupal_rewrite_settings() will reload Settings and update + // $GLOBALS['config'] accordingly. $this->writeSettings($settings); // Allow for test-specific overrides. $settings_testing_file = DRUPAL_ROOT . '/' . $this->originalSite . '/settings.testing.php'; @@ -666,6 +670,7 @@ protected function initSettings() { // TestBase::restoreEnvironment() will delete the entire site directory. // Not using File API; a potential error must trigger a PHP warning. chmod(DRUPAL_ROOT . '/' . $this->siteDirectory, 0777); + chmod(DRUPAL_ROOT . '/' . $this->siteDirectory . '/settings.php', 0666); // During tests, cacheable responses should get the debugging cacheability // headers by default. diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc index f9c7c5f..9fbcd0e 100644 --- a/core/modules/update/update.manager.inc +++ b/core/modules/update/update.manager.inc @@ -36,6 +36,7 @@ * root. */ +use Drupal\Core\Site\Site; use Symfony\Component\HttpFoundation\RedirectResponse; /** diff --git a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php index 7778a5a..bd3ed1b 100644 --- a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php +++ b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php @@ -4,6 +4,7 @@ use Drupal\Core\DrupalKernel; use Drupal\KernelTests\KernelTestBase; +use Drupal\Core\Site\Site; use Symfony\Component\HttpFoundation\Request; /** @@ -17,6 +18,9 @@ class DrupalKernelTest extends KernelTestBase { * {@inheritdoc} */ protected function setUp() { + // Initialize the test Site singleton, so that Site::getPath() works. + Site::init(DRUPAL_ROOT); + // DrupalKernel relies on global $config_directories and requires those // directories to exist. Therefore, create the directories, but do not // invoke KernelTestBase::setUp(), since that would set up further diff --git a/core/tests/Drupal/KernelTests/Core/File/ReadOnlyStreamWrapperTest.php b/core/tests/Drupal/KernelTests/Core/File/ReadOnlyStreamWrapperTest.php index ae19e02..c36c659 100644 --- a/core/tests/Drupal/KernelTests/Core/File/ReadOnlyStreamWrapperTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/ReadOnlyStreamWrapperTest.php @@ -2,6 +2,7 @@ namespace Drupal\KernelTests\Core\File; +use Drupal\Core\Site\Site; use Drupal\Core\StreamWrapper\StreamWrapperInterface; use Drupal\file_test\StreamWrapper\DummyReadOnlyStreamWrapper; diff --git a/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php b/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php index 948236b..c1a9e0c 100644 --- a/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php +++ b/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php @@ -4,6 +4,7 @@ use Drupal\Core\Site\Settings; use Drupal\KernelTests\KernelTestBase; +use Drupal\Core\Site\Site; /** * Tests the drupal_rewrite_settings() function. diff --git a/sites/default/default.services.yml b/sites/default/default.services.yml index e1bbbc7..792d600 100644 --- a/sites/default/default.services.yml +++ b/sites/default/default.services.yml @@ -1,174 +1 @@ -parameters: - session.storage.options: - # Default ini options for sessions. - # - # Some distributions of Linux (most notably Debian) ship their PHP - # installations with garbage collection (gc) disabled. Since Drupal depends - # on PHP's garbage collection for clearing sessions, ensure that garbage - # collection occurs by using the most common settings. - # @default 1 - gc_probability: 1 - # @default 100 - gc_divisor: 100 - # - # Set session lifetime (in seconds), i.e. the time from the user's last - # visit to the active session may be deleted by the session garbage - # collector. When a session is deleted, authenticated users are logged out, - # and the contents of the user's $_SESSION variable is discarded. - # @default 200000 - gc_maxlifetime: 200000 - # - # Set session cookie lifetime (in seconds), i.e. the time from the session - # is created to the cookie expires, i.e. when the browser is expected to - # discard the cookie. The value 0 means "until the browser is closed". - # @default 2000000 - cookie_lifetime: 2000000 - # - # Drupal automatically generates a unique session cookie name based on the - # full domain name used to access the site. This mechanism is sufficient - # for most use-cases, including multi-site deployments. However, if it is - # desired that a session can be reused across different subdomains, the - # cookie domain needs to be set to the shared base domain. Doing so assures - # that users remain logged in as they cross between various subdomains. - # To maximize compatibility and normalize the behavior across user agents, - # the cookie domain should start with a dot. - # - # @default none - # cookie_domain: '.example.com' - # - twig.config: - # Twig debugging: - # - # When debugging is enabled: - # - The markup of each Twig template is surrounded by HTML comments that - # contain theming information, such as template file name suggestions. - # - Note that this debugging markup will cause automated tests that directly - # check rendered HTML to fail. When running automated tests, 'debug' - # should be set to FALSE. - # - The dump() function can be used in Twig templates to output information - # about template variables. - # - Twig templates are automatically recompiled whenever the source code - # changes (see auto_reload below). - # - # For more information about debugging Twig templates, see - # https://www.drupal.org/node/1906392. - # - # Not recommended in production environments - # @default false - debug: false - # Twig auto-reload: - # - # Automatically recompile Twig templates whenever the source code changes. - # If you don't provide a value for auto_reload, it will be determined - # based on the value of debug. - # - # Not recommended in production environments - # @default null - auto_reload: null - # Twig cache: - # - # By default, Twig templates will be compiled and stored in the filesystem - # to increase performance. Disabling the Twig cache will recompile the - # templates from source each time they are used. In most cases the - # auto_reload setting above should be enabled rather than disabling the - # Twig cache. - # - # Not recommended in production environments - # @default true - cache: true - renderer.config: - # Renderer required cache contexts: - # - # The Renderer will automatically associate these cache contexts with every - # render array, hence varying every render array by these cache contexts. - # - # @default ['languages:language_interface', 'theme', 'user.permissions'] - required_cache_contexts: ['languages:language_interface', 'theme', 'user.permissions'] - # Renderer automatic placeholdering conditions: - # - # Drupal allows portions of the page to be automatically deferred when - # rendering to improve cache performance. That is especially helpful for - # cache contexts that vary widely, such as the active user. On some sites - # those may be different, however, such as sites with only a handful of - # users. If you know what the high-cardinality cache contexts are for your - # site, specify those here. If you're not sure, the defaults are fairly safe - # in general. - # - # For more information about rendering optimizations see - # https://www.drupal.org/developing/api/8/render/arrays/cacheability#optimizing - auto_placeholder_conditions: - # Max-age at or below which caching is not considered worthwhile. - # - # Disable by setting to -1. - # - # @default 0 - max-age: 0 - # Cache contexts with a high cardinality. - # - # Disable by setting to []. - # - # @default ['session', 'user'] - contexts: ['session', 'user'] - # Tags with a high invalidation frequency. - # - # Disable by setting to []. - # - # @default [] - tags: [] - # Cacheability debugging: - # - # Responses with cacheability metadata (CacheableResponseInterface instances) - # get X-Drupal-Cache-Tags and X-Drupal-Cache-Contexts headers. - # - # For more information about debugging cacheable responses, see - # https://www.drupal.org/developing/api/8/response/cacheable-response-interface - # - # Not recommended in production environments - # @default false - http.response.debug_cacheability_headers: false - factory.keyvalue: - {} - # Default key/value storage service to use. - # @default keyvalue.database - # default: keyvalue.database - # Collection-specific overrides. - # state: keyvalue.database - factory.keyvalue.expirable: - {} - # Default key/value expirable storage service to use. - # @default keyvalue.database.expirable - # default: keyvalue.database.expirable - # Allowed protocols for URL generation. - filter_protocols: - - http - - https - - ftp - - news - - nntp - - tel - - telnet - - mailto - - irc - - ssh - - sftp - - webcal - - rtsp - - # Configure Cross-Site HTTP requests (CORS). - # Read https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS - # for more information about the topic in general. - # Note: By default the configuration is disabled. - cors.config: - enabled: false - # Specify allowed headers, like 'x-allowed-header'. - allowedHeaders: [] - # Specify allowed request methods, specify ['*'] to allow all possible ones. - allowedMethods: [] - # Configure requests allowed from specific origins. - allowedOrigins: ['*'] - # Sets the Access-Control-Expose-Headers header. - exposedHeaders: false - # Sets the Access-Control-Max-Age header. - maxAge: false - # Sets the Access-Control-Allow-Credentials header. - supportsCredentials: false +# diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index 94a1e04..b3d9bbc 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -1,759 +1 @@ 'databasename', - * 'username' => 'sqlusername', - * 'password' => 'sqlpassword', - * 'host' => 'localhost', - * 'port' => '3306', - * 'driver' => 'mysql', - * 'prefix' => '', - * 'collation' => 'utf8mb4_general_ci', - * ); - * @endcode - */ - $databases = array(); - -/** - * Customizing database settings. - * - * Many of the values of the $databases array can be customized for your - * particular database system. Refer to the sample in the section above as a - * starting point. - * - * The "driver" property indicates what Drupal database driver the - * connection should use. This is usually the same as the name of the - * database type, such as mysql or sqlite, but not always. The other - * properties will vary depending on the driver. For SQLite, you must - * specify a database file name in a directory that is writable by the - * webserver. For most other drivers, you must specify a - * username, password, host, and database name. - * - * Transaction support is enabled by default for all drivers that support it, - * including MySQL. To explicitly disable it, set the 'transactions' key to - * FALSE. - * Note that some configurations of MySQL, such as the MyISAM engine, don't - * support it and will proceed silently even if enabled. If you experience - * transaction related crashes with such configuration, set the 'transactions' - * key to FALSE. - * - * For each database, you may optionally specify multiple "target" databases. - * A target database allows Drupal to try to send certain queries to a - * different database if it can but fall back to the default connection if not. - * That is useful for primary/replica replication, as Drupal may try to connect - * to a replica server when appropriate and if one is not available will simply - * fall back to the single primary server (The terms primary/replica are - * traditionally referred to as master/slave in database server documentation). - * - * The general format for the $databases array is as follows: - * @code - * $databases['default']['default'] = $info_array; - * $databases['default']['replica'][] = $info_array; - * $databases['default']['replica'][] = $info_array; - * $databases['extra']['default'] = $info_array; - * @endcode - * - * In the above example, $info_array is an array of settings described above. - * The first line sets a "default" database that has one primary database - * (the second level default). The second and third lines create an array - * of potential replica databases. Drupal will select one at random for a given - * request as needed. The fourth line creates a new database with a name of - * "extra". - * - * You can optionally set prefixes for some or all database table names - * by using the 'prefix' setting. If a prefix is specified, the table - * name will be prepended with its value. Be sure to use valid database - * characters only, usually alphanumeric and underscore. If no prefixes - * are desired, leave it as an empty string ''. - * - * To have all database names prefixed, set 'prefix' as a string: - * @code - * 'prefix' => 'main_', - * @endcode - * - * Per-table prefixes are deprecated as of Drupal 8.2, and will be removed in - * Drupal 9.0. After that, only a single prefix for all tables will be - * supported. - * - * To provide prefixes for specific tables, set 'prefix' as an array. - * The array's keys are the table names and the values are the prefixes. - * The 'default' element is mandatory and holds the prefix for any tables - * not specified elsewhere in the array. Example: - * @code - * 'prefix' => array( - * 'default' => 'main_', - * 'users' => 'shared_', - * 'sessions' => 'shared_', - * 'role' => 'shared_', - * 'authmap' => 'shared_', - * ), - * @endcode - * You can also use a reference to a schema/database as a prefix. This may be - * useful if your Drupal installation exists in a schema that is not the default - * or you want to access several databases from the same code base at the same - * time. - * Example: - * @code - * 'prefix' => array( - * 'default' => 'main.', - * 'users' => 'shared.', - * 'sessions' => 'shared.', - * 'role' => 'shared.', - * 'authmap' => 'shared.', - * ); - * @endcode - * NOTE: MySQL and SQLite's definition of a schema is a database. - * - * Advanced users can add or override initial commands to execute when - * connecting to the database server, as well as PDO connection settings. For - * example, to enable MySQL SELECT queries to exceed the max_join_size system - * variable, and to reduce the database connection timeout to 5 seconds: - * @code - * $databases['default']['default'] = array( - * 'init_commands' => array( - * 'big_selects' => 'SET SQL_BIG_SELECTS=1', - * ), - * 'pdo' => array( - * PDO::ATTR_TIMEOUT => 5, - * ), - * ); - * @endcode - * - * WARNING: The above defaults are designed for database portability. Changing - * them may cause unexpected behavior, including potential data loss. See - * https://www.drupal.org/developing/api/database/configuration for more - * information on these defaults and the potential issues. - * - * More details can be found in the constructor methods for each driver: - * - \Drupal\Core\Database\Driver\mysql\Connection::__construct() - * - \Drupal\Core\Database\Driver\pgsql\Connection::__construct() - * - \Drupal\Core\Database\Driver\sqlite\Connection::__construct() - * - * Sample Database configuration format for PostgreSQL (pgsql): - * @code - * $databases['default']['default'] = array( - * 'driver' => 'pgsql', - * 'database' => 'databasename', - * 'username' => 'sqlusername', - * 'password' => 'sqlpassword', - * 'host' => 'localhost', - * 'prefix' => '', - * ); - * @endcode - * - * Sample Database configuration format for SQLite (sqlite): - * @code - * $databases['default']['default'] = array( - * 'driver' => 'sqlite', - * 'database' => '/path/to/databasefilename', - * ); - * @endcode - */ - -/** - * Location of the site configuration files. - * - * The $config_directories array specifies the location of file system - * directories used for configuration data. On install, the "sync" directory is - * created. This is used for configuration imports. The "active" directory is - * not created by default since the default storage for active configuration is - * the database rather than the file system. (This can be changed. See "Active - * configuration settings" below). - * - * The default location for the "sync" directory is inside a randomly-named - * directory in the public files path. The setting below allows you to override - * the "sync" location. - * - * If you use files for the "active" configuration, you can tell the - * Configuration system where this directory is located by adding an entry with - * array key CONFIG_ACTIVE_DIRECTORY. - * - * Example: - * @code - * $config_directories = array( - * CONFIG_SYNC_DIRECTORY => '/directory/outside/webroot', - * ); - * @endcode - */ -$config_directories = array(); - -/** - * Settings: - * - * $settings contains environment-specific configuration, such as the files - * directory and reverse proxy address, and temporary configuration, such as - * security overrides. - * - * @see \Drupal\Core\Site\Settings::get() - */ - -/** - * The active installation profile. - * - * Changing this after installation is not recommended as it changes which - * directories are scanned during extension discovery. If this is set prior to - * installation this value will be rewritten according to the profile selected - * by the user. - * - * @see install_select_profile() - */ -# $settings['install_profile'] = ''; - -/** - * Salt for one-time login links, cancel links, form tokens, etc. - * - * This variable will be set to a random value by the installer. All one-time - * login links will be invalidated if the value is changed. Note that if your - * site is deployed on a cluster of web servers, you must ensure that this - * variable has the same value on each server. - * - * For enhanced security, you may set this variable to the contents of a file - * outside your document root; you should also ensure that this file is not - * stored with backups of your database. - * - * Example: - * @code - * $settings['hash_salt'] = file_get_contents('/home/example/salt.txt'); - * @endcode - */ -$settings['hash_salt'] = ''; - -/** - * Deployment identifier. - * - * Drupal's dependency injection container will be automatically invalidated and - * rebuilt when the Drupal core version changes. When updating contributed or - * custom code that changes the container, changing this identifier will also - * allow the container to be invalidated as soon as code is deployed. - */ -# $settings['deployment_identifier'] = \Drupal::VERSION; - -/** - * Access control for update.php script. - * - * If you are updating your Drupal installation using the update.php script but - * are not logged in using either an account with the "Administer software - * updates" permission or the site maintenance account (the account that was - * created during installation), you will need to modify the access check - * statement below. Change the FALSE to a TRUE to disable the access check. - * After finishing the upgrade, be sure to open this file again and change the - * TRUE back to a FALSE! - */ -$settings['update_free_access'] = FALSE; - -/** - * External access proxy settings: - * - * If your site must access the Internet via a web proxy then you can enter the - * proxy settings here. Set the full URL of the proxy, including the port, in - * variables: - * - $settings['http_client_config']['proxy']['http']: The proxy URL for HTTP - * requests. - * - $settings['http_client_config']['proxy']['https']: The proxy URL for HTTPS - * requests. - * You can pass in the user name and password for basic authentication in the - * URLs in these settings. - * - * You can also define an array of host names that can be accessed directly, - * bypassing the proxy, in $settings['http_client_config']['proxy']['no']. - */ -# $settings['http_client_config']['proxy']['http'] = 'http://proxy_user:proxy_pass@example.com:8080'; -# $settings['http_client_config']['proxy']['https'] = 'http://proxy_user:proxy_pass@example.com:8080'; -# $settings['http_client_config']['proxy']['no'] = ['127.0.0.1', 'localhost']; - -/** - * Reverse Proxy Configuration: - * - * Reverse proxy servers are often used to enhance the performance - * of heavily visited sites and may also provide other site caching, - * security, or encryption benefits. In an environment where Drupal - * is behind a reverse proxy, the real IP address of the client should - * be determined such that the correct client IP address is available - * to Drupal's logging, statistics, and access management systems. In - * the most simple scenario, the proxy server will add an - * X-Forwarded-For header to the request that contains the client IP - * address. However, HTTP headers are vulnerable to spoofing, where a - * malicious client could bypass restrictions by setting the - * X-Forwarded-For header directly. Therefore, Drupal's proxy - * configuration requires the IP addresses of all remote proxies to be - * specified in $settings['reverse_proxy_addresses'] to work correctly. - * - * Enable this setting to get Drupal to determine the client IP from - * the X-Forwarded-For header (or $settings['reverse_proxy_header'] if set). - * If you are unsure about this setting, do not have a reverse proxy, - * or Drupal operates in a shared hosting environment, this setting - * should remain commented out. - * - * In order for this setting to be used you must specify every possible - * reverse proxy IP address in $settings['reverse_proxy_addresses']. - * If a complete list of reverse proxies is not available in your - * environment (for example, if you use a CDN) you may set the - * $_SERVER['REMOTE_ADDR'] variable directly in settings.php. - * Be aware, however, that it is likely that this would allow IP - * address spoofing unless more advanced precautions are taken. - */ -# $settings['reverse_proxy'] = TRUE; - -/** - * Specify every reverse proxy IP address in your environment. - * This setting is required if $settings['reverse_proxy'] is TRUE. - */ -# $settings['reverse_proxy_addresses'] = array('a.b.c.d', ...); - -/** - * Set this value if your proxy server sends the client IP in a header - * other than X-Forwarded-For. - */ -# $settings['reverse_proxy_header'] = 'X_CLUSTER_CLIENT_IP'; - -/** - * Set this value if your proxy server sends the client protocol in a header - * other than X-Forwarded-Proto. - */ -# $settings['reverse_proxy_proto_header'] = 'X_FORWARDED_PROTO'; - -/** - * Set this value if your proxy server sends the client protocol in a header - * other than X-Forwarded-Host. - */ -# $settings['reverse_proxy_host_header'] = 'X_FORWARDED_HOST'; - -/** - * Set this value if your proxy server sends the client protocol in a header - * other than X-Forwarded-Port. - */ -# $settings['reverse_proxy_port_header'] = 'X_FORWARDED_PORT'; - -/** - * Set this value if your proxy server sends the client protocol in a header - * other than Forwarded. - */ -# $settings['reverse_proxy_forwarded_header'] = 'FORWARDED'; - -/** - * Page caching: - * - * By default, Drupal sends a "Vary: Cookie" HTTP header for anonymous page - * views. This tells a HTTP proxy that it may return a page from its local - * cache without contacting the web server, if the user sends the same Cookie - * header as the user who originally requested the cached page. Without "Vary: - * Cookie", authenticated users would also be served the anonymous page from - * the cache. If the site has mostly anonymous users except a few known - * editors/administrators, the Vary header can be omitted. This allows for - * better caching in HTTP proxies (including reverse proxies), i.e. even if - * clients send different cookies, they still get content served from the cache. - * However, authenticated users should access the site directly (i.e. not use an - * HTTP proxy, and bypass the reverse proxy if one is used) in order to avoid - * getting cached pages from the proxy. - */ -# $settings['omit_vary_cookie'] = TRUE; - - -/** - * Cache TTL for client error (4xx) responses. - * - * Items cached per-URL tend to result in a large number of cache items, and - * this can be problematic on 404 pages which by their nature are unbounded. A - * fixed TTL can be set for these items, defaulting to one hour, so that cache - * backends which do not support LRU can purge older entries. To disable caching - * of client error responses set the value to 0. Currently applies only to - * page_cache module. - */ -# $settings['cache_ttl_4xx'] = 3600; - - -/** - * Class Loader. - * - * If the APC extension is detected, the Symfony APC class loader is used for - * performance reasons. Detection can be prevented by setting - * class_loader_auto_detect to false, as in the example below. - */ -# $settings['class_loader_auto_detect'] = FALSE; - -/* - * If the APC extension is not detected, either because APC is missing or - * because auto-detection has been disabled, auto-loading falls back to - * Composer's ClassLoader, which is good for development as it does not break - * when code is moved in the file system. You can also decorate the base class - * loader with another cached solution than the Symfony APC class loader, as - * all production sites should have a cached class loader of some sort enabled. - * - * To do so, you may decorate and replace the local $class_loader variable. For - * example, to use Symfony's APC class loader without automatic detection, - * uncomment the code below. - */ -/* -if ($settings['hash_salt']) { - $prefix = 'drupal.' . hash('sha256', 'drupal.' . $settings['hash_salt']); - $apc_loader = new \Symfony\Component\ClassLoader\ApcClassLoader($prefix, $class_loader); - unset($prefix); - $class_loader->unregister(); - $apc_loader->register(); - $class_loader = $apc_loader; -} -*/ - -/** - * Authorized file system operations: - * - * The Update Manager module included with Drupal provides a mechanism for - * site administrators to securely install missing updates for the site - * directly through the web user interface. On securely-configured servers, - * the Update manager will require the administrator to provide SSH or FTP - * credentials before allowing the installation to proceed; this allows the - * site to update the new files as the user who owns all the Drupal files, - * instead of as the user the webserver is running as. On servers where the - * webserver user is itself the owner of the Drupal files, the administrator - * will not be prompted for SSH or FTP credentials (note that these server - * setups are common on shared hosting, but are inherently insecure). - * - * Some sites might wish to disable the above functionality, and only update - * the code directly via SSH or FTP themselves. This setting completely - * disables all functionality related to these authorized file operations. - * - * @see https://www.drupal.org/node/244924 - * - * Remove the leading hash signs to disable. - */ -# $settings['allow_authorize_operations'] = FALSE; - -/** - * Default mode for directories and files written by Drupal. - * - * Value should be in PHP Octal Notation, with leading zero. - */ -# $settings['file_chmod_directory'] = 0775; -# $settings['file_chmod_file'] = 0664; - -/** - * Public file base URL: - * - * An alternative base URL to be used for serving public files. This must - * include any leading directory path. - * - * A different value from the domain used by Drupal to be used for accessing - * public files. This can be used for a simple CDN integration, or to improve - * security by serving user-uploaded files from a different domain or subdomain - * pointing to the same server. Do not include a trailing slash. - */ -# $settings['file_public_base_url'] = 'http://downloads.example.com/files'; - -/** - * Public file path: - * - * A local file system path where public files will be stored. This directory - * must exist and be writable by Drupal. This directory must be relative to - * the Drupal installation directory and be accessible over the web. - */ -# $settings['file_public_path'] = 'sites/default/files'; - -/** - * Private file path: - * - * A local file system path where private files will be stored. This directory - * must be absolute, outside of the Drupal installation directory and not - * accessible over the web. - * - * Note: Caches need to be cleared when this value is changed to make the - * private:// stream wrapper available to the system. - * - * See https://www.drupal.org/documentation/modules/file for more information - * about securing private files. - */ -# $settings['file_private_path'] = ''; - -/** - * Session write interval: - * - * Set the minimum interval between each session write to database. - * For performance reasons it defaults to 180. - */ -# $settings['session_write_interval'] = 180; - -/** - * String overrides: - * - * To override specific strings on your site with or without enabling the Locale - * module, add an entry to this list. This functionality allows you to change - * a small number of your site's default English language interface strings. - * - * Remove the leading hash signs to enable. - * - * The "en" part of the variable name, is dynamic and can be any langcode of - * any added language. (eg locale_custom_strings_de for german). - */ -# $settings['locale_custom_strings_en'][''] = array( -# 'forum' => 'Discussion board', -# '@count min' => '@count minutes', -# ); - -/** - * A custom theme for the offline page: - * - * This applies when the site is explicitly set to maintenance mode through the - * administration page or when the database is inactive due to an error. - * The template file should also be copied into the theme. It is located inside - * 'core/modules/system/templates/maintenance-page.html.twig'. - * - * Note: This setting does not apply to installation and update pages. - */ -# $settings['maintenance_theme'] = 'bartik'; - -/** - * PHP settings: - * - * To see what PHP settings are possible, including whether they can be set at - * runtime (by using ini_set()), read the PHP documentation: - * http://php.net/manual/ini.list.php - * See \Drupal\Core\DrupalKernel::bootEnvironment() for required runtime - * settings and the .htaccess file for non-runtime settings. - * Settings defined there should not be duplicated here so as to avoid conflict - * issues. - */ - -/** - * If you encounter a situation where users post a large amount of text, and - * the result is stripped out upon viewing but can still be edited, Drupal's - * output filter may not have sufficient memory to process it. If you - * experience this issue, you may wish to uncomment the following two lines - * and increase the limits of these variables. For more information, see - * http://php.net/manual/pcre.configuration.php. - */ -# ini_set('pcre.backtrack_limit', 200000); -# ini_set('pcre.recursion_limit', 200000); - -/** - * Active configuration settings. - * - * By default, the active configuration is stored in the database in the - * {config} table. To use a different storage mechanism for the active - * configuration, do the following prior to installing: - * - Create an "active" directory and declare its path in $config_directories - * as explained under the 'Location of the site configuration files' section - * above in this file. To enhance security, you can declare a path that is - * outside your document root. - * - Override the 'bootstrap_config_storage' setting here. It must be set to a - * callable that returns an object that implements - * \Drupal\Core\Config\StorageInterface. - * - Override the service definition 'config.storage.active'. Put this - * override in a services.yml file in the same directory as settings.php - * (definitions in this file will override service definition defaults). - */ -# $settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage'); - -/** - * Configuration overrides. - * - * To globally override specific configuration values for this site, - * set them here. You usually don't need to use this feature. This is - * useful in a configuration file for a vhost or directory, rather than - * the default settings.php. - * - * Note that any values you provide in these variable overrides will not be - * viewable from the Drupal administration interface. The administration - * interface displays the values stored in configuration so that you can stage - * changes to other environments that don't have the overrides. - * - * There are particular configuration values that are risky to override. For - * example, overriding the list of installed modules in 'core.extension' is not - * supported as module install or uninstall has not occurred. Other examples - * include field storage configuration, because it has effects on database - * structure, and 'core.menu.static_menu_link_overrides' since this is cached in - * a way that is not config override aware. Also, note that changing - * configuration values in settings.php will not fire any of the configuration - * change events. - */ -# $config['system.site']['name'] = 'My Drupal site'; -# $config['system.theme']['default'] = 'stark'; -# $config['user.settings']['anonymous'] = 'Visitor'; - -/** - * Fast 404 pages: - * - * Drupal can generate fully themed 404 pages. However, some of these responses - * are for images or other resource files that are not displayed to the user. - * This can waste bandwidth, and also generate server load. - * - * The options below return a simple, fast 404 page for URLs matching a - * specific pattern: - * - $config['system.performance']['fast_404']['exclude_paths']: A regular - * expression to match paths to exclude, such as images generated by image - * styles, or dynamically-resized images. The default pattern provided below - * also excludes the private file system. If you need to add more paths, you - * can add '|path' to the expression. - * - $config['system.performance']['fast_404']['paths']: A regular expression to - * match paths that should return a simple 404 page, rather than the fully - * themed 404 page. If you don't have any aliases ending in htm or html you - * can add '|s?html?' to the expression. - * - $config['system.performance']['fast_404']['html']: The html to return for - * simple 404 pages. - * - * Remove the leading hash signs if you would like to alter this functionality. - */ -# $config['system.performance']['fast_404']['exclude_paths'] = '/\/(?:styles)|(?:system\/files)\//'; -# $config['system.performance']['fast_404']['paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; -# $config['system.performance']['fast_404']['html'] = '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

'; - -/** - * Load services definition file. - */ -$settings['container_yamls'][] = __DIR__ . '/services.yml'; - -/** - * Override the default service container class. - * - * This is useful for example to trace the service container for performance - * tracking purposes, for testing a service container with an error condition or - * to test a service container that throws an exception. - */ -# $settings['container_base_class'] = '\Drupal\Core\DependencyInjection\Container'; - -/** - * Override the default yaml parser class. - * - * Provide a fully qualified class name here if you would like to provide an - * alternate implementation YAML parser. The class must implement the - * \Drupal\Component\Serialization\SerializationInterface interface. - */ -# $settings['yaml_parser_class'] = NULL; - -/** - * Trusted host configuration. - * - * Drupal core can use the Symfony trusted host mechanism to prevent HTTP Host - * header spoofing. - * - * To enable the trusted host mechanism, you enable your allowable hosts - * in $settings['trusted_host_patterns']. This should be an array of regular - * expression patterns, without delimiters, representing the hosts you would - * like to allow. - * - * For example: - * @code - * $settings['trusted_host_patterns'] = array( - * '^www\.example\.com$', - * ); - * @endcode - * will allow the site to only run from www.example.com. - * - * If you are running multisite, or if you are running your site from - * different domain names (eg, you don't redirect http://www.example.com to - * http://example.com), you should specify all of the host patterns that are - * allowed by your site. - * - * For example: - * @code - * $settings['trusted_host_patterns'] = array( - * '^example\.com$', - * '^.+\.example\.com$', - * '^example\.org$', - * '^.+\.example\.org$', - * ); - * @endcode - * will allow the site to run off of all variants of example.com and - * example.org, with all subdomains included. - */ - -/** - * The default list of directories that will be ignored by Drupal's file API. - * - * By default ignore node_modules and bower_components folders to avoid issues - * with common frontend tools and recursive scanning of directories looking for - * extensions. - * - * @see file_scan_directory() - * @see \Drupal\Core\Extension\ExtensionDiscovery::scanDirectory() - */ -$settings['file_scan_ignore_directories'] = [ - 'node_modules', - 'bower_components', -]; - -/** - * Load local development override configuration, if available. - * - * Use settings.local.php to override variables on secondary (staging, - * development, etc) installations of this site. Typically used to disable - * caching, JavaScript/CSS compression, re-routing of outgoing emails, and - * other things that should not happen on development and testing sites. - * - * Keep this code block at the end of this file to take full effect. - */ -# if (file_exists(__DIR__ . '/settings.local.php')) { -# include __DIR__ . '/settings.local.php'; -# } diff --git a/sites/example.sites.php b/sites/example.sites.php deleted file mode 100644 index 60afae7..0000000 --- a/sites/example.sites.php +++ /dev/null @@ -1,55 +0,0 @@ -..' => 'directory'. As an - * example, to map https://www.drupal.org:8080/mysite/test to the configuration - * directory sites/example.com, the array should be defined as: - * @code - * $sites = array( - * '8080.www.drupal.org.mysite.test' => 'example.com', - * ); - * @endcode - * The URL, https://www.drupal.org:8080/mysite/test/, could be a symbolic link - * or an Apache Alias directive that points to the Drupal root containing - * index.php. An alias could also be created for a subdomain. See the - * @link https://www.drupal.org/documentation/install online Drupal installation guide @endlink - * for more information on setting up domains, subdomains, and subdirectories. - * - * The following examples look for a site configuration in sites/example.com: - * @code - * URL: http://dev.drupal.org - * $sites['dev.drupal.org'] = 'example.com'; - * - * URL: http://localhost/example - * $sites['localhost.example'] = 'example.com'; - * - * URL: http://localhost:8080/example - * $sites['8080.localhost.example'] = 'example.com'; - * - * URL: https://www.drupal.org:8080/mysite/test/ - * $sites['8080.www.drupal.org.mysite.test'] = 'example.com'; - * @endcode - * - * @see default.settings.php - * @see \Drupal\Core\DrupalKernel::getSitePath() - * @see https://www.drupal.org/documentation/install/multi-site - */