diff --git a/core/INSTALL.txt b/core/INSTALL.txt index b753f3a..9302945 100644 --- a/core/INSTALL.txt +++ b/core/INSTALL.txt @@ -150,12 +150,12 @@ INSTALLATION 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. + core/default.settings.php as a template. 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 sites/default/settings.php Next, grant write privileges to the file to everyone (including the web server) with the command: diff --git a/core/UPGRADE.txt b/core/UPGRADE.txt index f035b6c..57021fb 100644 --- a/core/UPGRADE.txt +++ b/core/UPGRADE.txt @@ -163,10 +163,6 @@ following the instructions in the INTRODUCTION section at the top of this file: no longer need their data, then you can uninstall them under the Uninstall tab after disabling them. -8. On the command line or in your FTP client, remove the file - - sites/default/default.settings.php - 9. Remove all old core files and directories, except for the 'sites' directory and any custom files you added elsewhere. diff --git a/core/default.settings.php b/core/default.settings.php new file mode 100644 index 0000000..0de6589 --- /dev/null +++ b/core/default.settings.php @@ -0,0 +1,708 @@ +..' => 'directory', + * @endcode + * For example, to map http://www.drupal.org:8080/mysite/test to the directory + * sites/example.com, the array should be defined as: + * @code + * $sites['8080.www.drupal.org.mysite.test'] = 'example.com'; + * @endcode + * The URL http://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 http://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: http://www.drupal.org:8080/mysite/test/ + * $sites['8080.www.drupal.org.mysite.test'] = 'example.com'; + * @endcode + * + * @see http://drupal.org/documentation/install/multi-site + */ +# $sites = array(); +# $sites['localhost.example'] = 'example.com'; + +/** + * Database settings: + * + * The $databases array specifies the database connection or + * connections that Drupal may use. Drupal is able to connect + * to multiple databases, including multiple types of databases, + * during the same request. + * + * Each database connection is specified as an array of settings, + * similar to the following: + * @code + * array( + * 'driver' => '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 master/slave replication, as Drupal may try to connect + * to a slave server when appropriate and if one is not available will simply + * fall back to the single master server. + * + * The general format for the $databases array is as follows: + * @code + * $databases['default']['default'] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['default']['slave'][] = $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 master database + * (the second level default). The second and third lines create an array + * of potential slave 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(); + +/** + * Salt for one-time login links and 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. If this variable is empty, a hash + * of the serialized database credentials will be used as a fallback salt. + * + * For enhanced security, you may set this variable to a value using the + * contents of a file outside your docroot that is never saved together + * with any backups of your Drupal files and database. + * + * Example: + * $drupal_hash_salt = file_get_contents('/home/example/salt.txt'); + * + */ +$drupal_hash_salt = ''; + +/** + * Location of the site configuration files. + * + * By default, Drupal configuration files are stored in a randomly named + * directory under the default public files path. On install the + * named directory is created in the default files directory. For enhanced + * security, you may set this variable to a location outside your docroot. + * + * @todo Flesh this out, provide more details, etc. + * + * 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 configuration that can not be saved in the configuration + * system because it is required too early during bootstrap like the database + * information. It is also used for configuration that is specific for a given + * environment like reverse proxy settings + * + * @see settings_get() + */ + +/** + * 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; + +/** + * 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). + */ +# $settings['twig_debug'] = TRUE; + +/** + * 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). + */ +# $settings['twig_auto_reload'] = TRUE; + +/** + * 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). + */ +# $settings['twig_cache'] = 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, Drupal uses Composer's ClassLoader, which is best for + * development, as it does not break when code is moved on the file + * system. It is possible, however, to wrap the class loader with a + * cached class loader solution for better performance, which is + * recommended for production sites. + * + * Examples: + * $settings['class_loader'] = 'apc'; + * $settings['class_loader'] = 'default'; + */ +# $settings['class_loader'] = 'apc'; + +/** + * 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; + +/** + * 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 enabled 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'; + +/** + * Enable access to rebuild.php. + * + * This setting can be enabled to allow Drupal's php and database cached + * storage to be cleared via the rebuild.php page. Access to this page can also + * be gained by generating a query string from rebuild_token_calculator.sh and + * using these parameters in a request to rebuild.php. + */ +# $settings['rebuild_access'] = TRUE; + +/** + * 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_environment_initialize() in core/includes/bootstrap.inc 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'; + +/** + * Variable overrides: + * + * To override specific entries in the 'variable' table 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. Any configuration setting from the 'variable' + * table can be given a new value. Note that any values you provide in + * these variable overrides will not be modifiable from the Drupal + * administration interface. + * + * The following overrides are examples: + * - site_name: Defines the site's name. + * - $conf['system.theme']['default']: Defines the default theme for this site. + * - anonymous: Defines the human-readable name of anonymous users. + * Remove the leading hash signs to enable. + */ +# $conf['system.site']['name'] = 'My Drupal site'; +# $conf['system.theme']['default'] = 'stark'; +# $conf['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. + */ +# $conf['system.performance']['css']['gzip'] = FALSE; +# $conf['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. + */ +#$conf['system.performance']['fast_404']['exclude_paths'] = '/\/(?:styles)\//'; +#$conf['system.performance']['fast_404']['paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; +#$conf['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 e-mails, 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(DRUPAL_ROOT . '/' . $conf_path . '/settings.local.php')) { +# include DRUPAL_ROOT . '/' . $conf_path . '/settings.local.php'; +# } diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index d995e32..2d227c8 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -12,6 +12,7 @@ use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Utility\Title; use Drupal\Core\Utility\Error; +use Drupal\Core\Utility\Site; use Symfony\Component\ClassLoader\ApcClassLoader; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Container; @@ -249,155 +250,31 @@ function timer_stop($name) { /** * Returns the appropriate configuration directory. * - * Returns the configuration path based on the site's hostname, port, and - * pathname. Uses find_conf_path() to find the current configuration directory. - * See default.settings.php for examples on how the URL is converted to a - * directory. - * - * @param bool $require_settings - * Only configuration directories with an existing settings.php file - * will be recognized. Defaults to TRUE. During initial installation, - * this is set to FALSE so that Drupal can detect a matching directory, - * then create a new settings.php file in it. + * @param string $custom_path + * (optional) A custom $conf_path to set and statically cache. * @param bool $reset * Force a full search for matching directories even if one had been * found previously. Defaults to FALSE. * - * @return - * The path of the matching directory. - * - * @see default.settings.php + * @deprecated Use \Drupal\Core\Utility\Site::getPath() instead. */ -function conf_path($require_settings = TRUE, $reset = FALSE) { - $conf_path = &drupal_static(__FUNCTION__, ''); - - if ($conf_path && !$reset) { - return $conf_path; +function conf_path($custom_path = NULL, $reset = FALSE) { + if (!empty($custom_path) && is_string($custom_path)) { + Site::setPath($custom_path); } - - // Check for a simpletest override. - if ($simpletest_conf_path = _drupal_simpletest_conf_path()) { - $conf_path = $simpletest_conf_path; - return $conf_path; - } - - // Otherwise, use the normal $conf_path. - $script_name = $_SERVER['SCRIPT_NAME']; - if (!$script_name) { - $script_name = $_SERVER['SCRIPT_FILENAME']; + if ($reset) { + Site::reset(); } - $http_host = $_SERVER['HTTP_HOST']; - $conf_path = find_conf_path($http_host, $script_name, $require_settings); - return $conf_path; -} - -/** - * Determines whether to use an overridden value for conf_path(). - * - * Simpletest may provide a secondary, test-specific settings.php file to load - * after the primary one used by the parent site and override its variables. - * - If the child settings.php does not override $conf_path, then this function - * returns FALSE and conf_path() returns the directory of the primary - * settings.php. - * - If the child settings.php does override $conf_path, then - * _drupal_load_test_overrides() sets the 'simpletest_conf_path' setting, and - * this function returns that to conf_path(), causing installations and - * upgrades to act on that one. - * - * @return string|false - * The overridden $conf_path, or FALSE if the $conf_path should not currently - * be overridden. - * - * @see conf_path() - * @see _drupal_load_test_overrides() - */ -function _drupal_simpletest_conf_path() { - // Ensure that the settings object is available. conf_path() is called once - // before the Settings class is included, and at that point it should still - // load the primary $conf_path. See drupal_settings_initialize(). - if (!class_exists('Drupal\Component\Utility\Settings', FALSE)) { - return FALSE; - } - - // If no $simpletest_conf_path is set, use the normal $conf_path. - if (!($simpletest_conf_path = settings()->get('simpletest_conf_path'))) { - return FALSE; - } - - // Ensure that this is actually a simpletest request. We can't check this - // before settings.php is loaded. - if (!drupal_valid_test_ua()) { - return FALSE; - } - - // When the $simpletest_conf_path is set in a valid test request, - // return that path. - return $simpletest_conf_path; + return Site::getPath(); } /** * Finds the appropriate configuration directory for a given host and path. * - * Finds a matching configuration directory file by stripping the website's - * hostname from left to right and pathname from right to left. By default, - * the directory must contain a 'settings.php' file for it to match. If the - * parameter $require_settings is set to FALSE, then a directory without a - * 'settings.php' file will match as well. The first configuration - * file found will be used and the remaining ones will be ignored. If no - * configuration file is found, returns a default value '$confdir/default'. See - * default.settings.php for examples on how the URL is converted to a directory. - * - * If a file named sites.php is present in the $confdir, it will be loaded - * prior to scanning for directories. That file can define aliases in an - * associative array named $sites. The array is written in the format - * '..' => 'directory'. As an 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 = array( - * '8080.www.drupal.org.mysite.test' => 'example.com', - * ); - * @endcode - * - * @param $http_host - * The hostname and optional port number, e.g. "www.example.com" or - * "www.example.com:8080". - * @param $script_name - * The part of the URL following the hostname, including the leading slash. - * @param $require_settings - * Defaults to TRUE. If TRUE, then only match directories with a - * 'settings.php' file. Otherwise match any directory. - * - * @return - * The path of the matching configuration directory. - * - * @see default.settings.php - * @see example.sites.php - * @see conf_path() + * @deprecated Use \Drupal\Core\Utility\Site::getMultisitePath() instead. */ -function find_conf_path($http_host, $script_name, $require_settings = TRUE) { - // Determine whether multi-site functionality is enabled. - if (!file_exists(DRUPAL_ROOT . '/sites/sites.php')) { - return 'sites/default'; - } - - $sites = array(); - include DRUPAL_ROOT . '/sites/sites.php'; - - $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)); - if (isset($sites[$dir]) && file_exists(DRUPAL_ROOT . '/sites/' . $sites[$dir])) { - $dir = $sites[$dir]; - } - if (file_exists(DRUPAL_ROOT . '/sites/' . $dir . '/settings.php') || (!$require_settings && file_exists(DRUPAL_ROOT . '/sites/' . $dir))) { - return "sites/$dir"; - } - } - } - return 'sites/default'; +function find_conf_path($http_host, $script_name, $require_settings = TRUE, array $sites = array()) { + return $site->getMultisitePath($http_host, $script_name, $require_settings, $sites); } /** @@ -451,7 +328,7 @@ function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) { * excluding any GET request but including the script name * (e.g., http://www.example.com/mysite/index.php). * - * @see conf_path() + * @see \Drupal\Core\Utility\Site::getPath() * @see request_uri() * @see \Symfony\Component\HttpFoundation\Request::getClientIP() */ @@ -484,7 +361,8 @@ function drupal_override_server_variables($variables = array()) { // Replace elements of the $_SERVER array, as appropriate. $request->server->replace($variables + $server_vars + $defaults); - // @todo remove once conf_path() no longer uses $_SERVER. + // @todo remove once \Drupal\Core\Utility\Site::getMultisitePath() no longer + // uses $_SERVER. $_SERVER = $request->server->all(); } @@ -523,7 +401,7 @@ function drupal_environment_initialize() { error_reporting(E_STRICT | E_ALL | error_reporting()); // Override PHP settings required for Drupal to work properly. - // sites/default/default.settings.php contains more runtime settings. + // default.settings.php contains more runtime settings. // The .htaccess file contains settings that cannot be changed at runtime. // Deny execution with enabled "magic quotes" (both GPC and runtime). @@ -561,22 +439,41 @@ function drupal_valid_http_host($host) { /** * Sets the base URL, cookie domain, and session name from configuration. + * + * @param bool $require_settings + * (optional) Whether to require settings.php to exist. Internally used by the + * Drupal installer, which needs to set up global variables before any + * configuration exists. */ -function drupal_settings_initialize() { +function drupal_settings_initialize($require_settings = TRUE) { global $base_url, $base_path, $base_root, $script_path; // Export these settings.php variables to the global namespace. - global $databases, $cookie_domain, $conf, $db_prefix, $drupal_hash_salt, $base_secure_url, $base_insecure_url, $config_directories; + global $sites, $databases, $cookie_domain, $conf, $db_prefix, $drupal_hash_salt, $base_secure_url, $base_insecure_url, $config_directories; $conf = array(); + // Include the global settings.php to determine whether the multi-site + // functionality is enabled. If settings.php is not required, then the caller + // is likely the installer, in which case the global settings.php may be used + // to enable the multi-site functionality to install Drupal into a + // site-specific directory. + if ($require_settings || is_readable(DRUPAL_ROOT . '/settings.php')) { + require_once DRUPAL_ROOT . '/settings.php'; + } - // Make conf_path() available as local variable in settings.php. - $conf_path = conf_path(); - if (is_readable(DRUPAL_ROOT . '/' . $conf_path . '/settings.php')) { - include_once DRUPAL_ROOT . '/' . $conf_path . '/settings.php'; + // Discover the site directory, priming the static cache in + // Site::determinePath(). Make $conf_path available as a local variable in + // settings.php. + if (isset($conf_path)) { + Site::setPath($conf_path); + } + $conf_path = Site::getPath(); + if (isset($sites) && Site::getPath() !== '.' && is_readable(Site::getAbsolutePath('settings.php'))) { + include_once Site::getAbsolutePath('settings.php'); } require_once __DIR__ . '../../lib/Drupal/Component/Utility/Settings.php'; new Settings(isset($settings) ? $settings : array()); + $is_https = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on'; if (isset($base_url)) { @@ -1953,7 +1850,7 @@ function _drupal_exception_handler($exception) { function _drupal_bootstrap_configuration() { drupal_environment_initialize(); // Initialize the configuration, including variables from settings.php. - drupal_settings_initialize(); + drupal_settings_initialize(!drupal_installation_attempted()); // Make sure we are using the test database prefix in child Drupal sites. _drupal_initialize_db_test_prefix(); @@ -1970,13 +1867,18 @@ function _drupal_bootstrap_configuration() { // Load the procedural configuration system helper functions. require_once __DIR__ . '/config.inc'; - // Set the Drupal custom error handler. (requires \Drupal::config()) + // Set the Drupal custom error handler. + // Circular dependency: The error/exception handler requires config, which + // requires the service container, which requires the class loader, which + // requires $conf/settings.php (to be swappable). Therefore, errors in early + // bootstrap and settings.php cannot be handled by Drupal. set_error_handler('_drupal_error_handler'); set_exception_handler('_drupal_exception_handler'); // Redirect the user to the installation script if Drupal has not been // installed yet (i.e., if no $databases array has been defined in the // settings.php file) and we are not already installing. + // @todo This is impossible and incompatible with a required /settings.php. if (empty($GLOBALS['databases']) && !drupal_installation_attempted() && !drupal_is_cli()) { include_once __DIR__ . '/install.inc'; install_goto('core/install.php'); @@ -2252,7 +2154,7 @@ function drupal_valid_test_ua($new_prefix = NULL) { * * Loads settings.php from the simpletest public files directory. These files * can change the global $conf, the global $config_directories, the return - * value of conf_path(), and settings(). + * value of \Drupal\Core\Utility\Site::getPath(), and settings(). * * @param string $test_prefix * The simpletest prefix. @@ -2265,18 +2167,18 @@ function _drupal_load_test_overrides($test_prefix) { $path_prefix = 'simpletest/' . substr($test_prefix, 10); $config_directories = array(); foreach (array(CONFIG_ACTIVE_DIRECTORY, CONFIG_STAGING_DIRECTORY) as $type) { - $config_directories[$type] = conf_path() . '/files/' . $path_prefix . '/config_' . $type; + $config_directories[$type] = Site::getPath('files/' . $path_prefix . '/config_' . $type); } // Check for and load a settings.php file in the simpletest files directory. - $filename = conf_path() . '/files/' . $path_prefix . '/settings.php'; + $filename = Site::getPath('/files/' . $path_prefix . '/settings.php'); if (file_exists($filename)) { $settings = settings()->getAll(); $conf_path = &drupal_static('conf_path'); // This can override $conf, $conf_path, $settings, and $config_directories. include $filename; // Keep the overriden $conf_path alive across drupal_static_reset() calls. - // @see conf_path() + // @see \Drupal\Core\Utility\Site::getSimpletestPath() $settings['simpletest_conf_path'] = $conf_path; new Settings($settings); } diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 46fbcbc..43085da 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -11,6 +11,7 @@ use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; use Drupal\Core\StringTranslation\Translator\FileTranslation; +use Drupal\Core\Utility\Site; use Drupal\Core\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -283,20 +284,22 @@ function install_begin_request(&$install_state) { drupal_override_server_variables($install_state['server']); } - // Initialize conf_path(). - // This primes the site path to be used during installation. By not requiring - // settings.php, a bare site folder can be prepared in the /sites directory, - // which will be used for installing Drupal. - conf_path(FALSE); - + // Perform a minimal bootstrap. + // This essentially calls _drupal_bootstrap_configuration(), which in turn + // calls drupal_settings_initialize() using the return value of + // drupal_installation_attempted() as argument. During installation, this + // causes drupal_settings_initialize() to not attempt to load any settings.php + // files, which allows to prime the site path to be used during installation. + // By not requiring settings.php, a bare site folder can be prepared in the + // /sites directory, which will be used for installing Drupal. drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); // If the hash salt leaks, it becomes possible to forge a valid testing user // agent, install a new copy of Drupal, and take over the original site. To // avoid this yet allow for automated testing of the installer, make sure - // there is also a special test-specific settings.php overriding conf_path(). - // _drupal_load_test_overrides() sets the simpletest_conf_path in-memory - // setting in this case. + // there is also a special test-specific settings.php overriding the site + // configuration directory path. _drupal_load_test_overrides() sets the + // simpletest_conf_path in-memory setting in this case. if ($install_state['interactive'] && drupal_valid_test_ua() && !settings()->get('simpletest_conf_path')) { header($request->server->get('SERVER_PROTOCOL') . ' 403 Forbidden'); exit; @@ -1080,8 +1083,7 @@ function install_verify_database_settings() { global $databases; if (!empty($databases)) { $database = $databases['default']['default']; - drupal_static_reset('conf_path'); - $settings_file = './' . conf_path(FALSE) . '/settings.php'; + $settings_file = Site::getPath('settings.php'); $errors = install_database_errors($database, $settings_file); if (empty($errors)) { return TRUE; @@ -1103,9 +1105,7 @@ function install_verify_database_settings() { function install_settings_form($form, &$form_state, &$install_state) { global $databases; - drupal_static_reset('conf_path'); - $conf_path = './' . conf_path(FALSE); - $settings_file = $conf_path . '/settings.php'; + $settings_file = Site::getPath('settings.php'); $database = isset($databases['default']['default']) ? $databases['default']['default'] : array(); drupal_set_title(t('Database configuration')); @@ -1501,7 +1501,7 @@ function install_translations_directory() { $directory = $GLOBALS['conf']['locale.settings']['translation.path']; } else { - $directory = conf_path() . '/files/translations'; + $directory = Site::getPath('files/translations'); } return $directory; } @@ -2083,8 +2083,8 @@ function install_configure_form($form, &$form_state, &$install_state) { drupal_set_title(t('Configure site')); // Warn about settings.php permissions risk - $settings_dir = conf_path(); - $settings_file = $settings_dir . '/settings.php'; + $settings_dir = Site::getPath(); + $settings_file = Site::getPath('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 @@ -2093,7 +2093,7 @@ function install_configure_form($form, &$form_state, &$install_state) { // distract from the message that the Drupal installation has completed // successfully.) $post_params = \Drupal::request()->request->all(); - if (empty($post_params) && (!drupal_verify_install_file(DRUPAL_ROOT . '/' . $settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE) || !drupal_verify_install_file(DRUPAL_ROOT . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) { + if (empty($post_params) && (!drupal_verify_install_file(Site::getAbsolutePath('settings.php'), FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE) || !drupal_verify_install_file(Site::getAbsolutePath(), FILE_NOT_WRITABLE, 'dir'))) { drupal_set_message(t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the online handbook.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'http://drupal.org/server-permissions')), 'warning'); } @@ -2239,8 +2239,8 @@ function install_check_translations($install_state) { $readable = FALSE; $writable = FALSE; // @todo: Make this configurable. - $files_directory = conf_path() . '/files'; - $translations_directory = conf_path() . '/files/translations'; + $files_directory = Site::getPath('files'); + $translations_directory = Site::getPath('files/translations'); $translations_directory_exists = FALSE; $translation_available = FALSE; $online = FALSE; @@ -2393,13 +2393,13 @@ function install_check_requirements($install_state) { if (!$install_state['settings_verified']) { $readable = FALSE; $writable = FALSE; - $conf_path = './' . conf_path(FALSE, TRUE); - $settings_file = $conf_path . '/settings.php'; - $default_settings_file = './sites/default/default.settings.php'; + $settings_file = Site::getPath('settings.php'); + $default_settings_file = './core/default.settings.php'; + $conf_path = Site::getPath(); $file = $conf_path; $exists = FALSE; // Verify that the directory exists. - if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) { + if (drupal_verify_install_file(Site::getPath(), FILE_EXIST, 'dir')) { // Check if a settings.php file already exists. $file = $settings_file; if (drupal_verify_install_file($settings_file, FILE_EXIST)) { @@ -2410,19 +2410,9 @@ function install_check_requirements($install_state) { } } - // If default.settings.php does not exist, or is not readable, throw an - // error. - if (!drupal_verify_install_file($default_settings_file, FILE_EXIST|FILE_READABLE)) { - $requirements['default settings file exists'] = array( - 'title' => t('Default settings file'), - 'value' => t('The default settings file does not exist.'), - 'severity' => REQUIREMENT_ERROR, - 'description' => t('The @drupal installer requires that the %default-file file not be modified in any way from the original download.', array('@drupal' => drupal_install_profile_distribution_name(), '%default-file' => $default_settings_file)), - ); - } // Otherwise, if settings.php does not exist yet, we can try to copy // default.settings.php to create it. - elseif (!$exists) { + if (!$exists) { $copied = drupal_verify_install_file($conf_path, FILE_EXIST|FILE_WRITABLE, 'dir') && @copy($default_settings_file, $settings_file); if ($copied) { // If the new settings file has the same owner as default.settings.php, diff --git a/core/includes/install.inc b/core/includes/install.inc index 256c79e..8af0be0 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -7,8 +7,10 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Drupal\Component\Utility\Crypt; +use Drupal\Component\Utility\Path; use Drupal\Core\Database\Database; use Drupal\Core\DrupalKernel; +use Drupal\Core\Utility\Site; /** * Requirement severity -- Informational message only. @@ -195,7 +197,7 @@ function drupal_get_database_types() { */ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { if (!isset($settings_file)) { - $settings_file = conf_path(FALSE) . '/settings.php'; + $settings_file = Site::getPath('settings.php'); } // Build list of setting names and insert the values into the global namespace. $variable_names = array(); @@ -305,12 +307,15 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { // Write the new settings file. if (file_put_contents(DRUPAL_ROOT . '/' . $settings_file, $buffer) === FALSE) { + Site::reset(); throw new Exception(t('Failed to modify %settings. Verify the file permissions.', array('%settings' => $settings_file))); } } else { + Site::reset(); throw new Exception(t('Failed to open %settings. Verify the file permissions.', array('%settings' => $settings_file))); } + Site::reset(); } /** @@ -449,11 +454,11 @@ function drupal_install_config_directories($mode = NULL) { $config_directories_hash = Crypt::randomStringHashed(55); $settings['config_directories'] = array( CONFIG_ACTIVE_DIRECTORY => (object) array( - 'value' => conf_path() . '/files/config_' . $config_directories_hash . '/active', + 'value' => Site::getPath('files/config_' . $config_directories_hash . '/active'), 'required' => TRUE, ), CONFIG_STAGING_DIRECTORY => (object) array( - 'value' => conf_path() . '/files/config_' . $config_directories_hash . '/staging', + 'value' => Site::getPath('files/config_' . $config_directories_hash . '/staging'), 'required' => TRUE, ), ); diff --git a/core/includes/update.inc b/core/includes/update.inc index 24f6583..e56cca1 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -15,6 +15,7 @@ use Drupal\Core\Config\ConfigException; use Drupal\Core\DrupalKernel; use Drupal\Core\Utility\Error; +use Drupal\Core\Utility\Site; use Drupal\Component\Uuid\Uuid; use Drupal\Component\Utility\NestedArray; use Symfony\Component\HttpFoundation\Request; @@ -124,7 +125,7 @@ function update_prepare_d8_bootstrap() { // If any of the required settings needs to be written, then settings.php // needs to be writable. if (!$settings_exist) { - $settings_file = conf_path() . '/settings.php'; + $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) { diff --git a/core/lib/Drupal/Component/Utility/Path.php b/core/lib/Drupal/Component/Utility/Path.php new file mode 100644 index 0000000..709d4a3 --- /dev/null +++ b/core/lib/Drupal/Component/Utility/Path.php @@ -0,0 +1,57 @@ + drupal_install_profile_distribution_name())); - $default_database = conf_path(FALSE, TRUE) . '/files/.ht.sqlite'; + $default_database = Site::getPath('files/.ht.sqlite'); $form['database']['#default_value'] = empty($database['database']) ? $default_database : $database['database']; return $form; } diff --git a/core/lib/Drupal/Core/StreamWrapper/PublicStream.php b/core/lib/Drupal/Core/StreamWrapper/PublicStream.php index 90f17b3..4fdf72b 100644 --- a/core/lib/Drupal/Core/StreamWrapper/PublicStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/PublicStream.php @@ -6,6 +6,7 @@ */ namespace Drupal\Core\StreamWrapper; +use Drupal\Core\Utility\Site; /** * Defines a Drupal public (public://) stream wrapper class. @@ -37,7 +38,7 @@ public function getExternalUrl() { * The base path for public:// typically sites/default/files. */ public static function basePath() { - $base_path = settings()->get('file_public_path', conf_path() . '/files'); + $base_path = settings()->get('file_public_path', Site::getPath('files')); if ($test_prefix = drupal_valid_test_ua()) { // Append the testing suffix unless already given. // @see \Drupal\simpletest\WebTestBase::setUp() diff --git a/core/lib/Drupal/Core/SystemListing.php b/core/lib/Drupal/Core/SystemListing.php index 20d95cb..923ee29 100644 --- a/core/lib/Drupal/Core/SystemListing.php +++ b/core/lib/Drupal/Core/SystemListing.php @@ -6,6 +6,7 @@ */ namespace Drupal\Core; +use Drupal\Core\Utility\Site; /** * Returns information about system object files (modules, themes, etc.). @@ -85,7 +86,6 @@ function scan($mask, $directory, $key = 'name') { if (!in_array($key, array('uri', 'filename', 'name'))) { $key = 'uri'; } - $config = conf_path(); // Search for the directory in core. $searchdir = array('core/' . $directory); @@ -100,8 +100,8 @@ function scan($mask, $directory, $key = 'name') { $searchdir[] = $directory; $searchdir[] = 'sites/all/' . $directory; - if (file_exists("$config/$directory")) { - $searchdir[] = "$config/$directory"; + if (file_exists(Site::getPath($directory))) { + $searchdir[] = Site::getPath($directory); } // @todo Find a way to skip ./config directories (but not modules/config). $nomask = '/^(CVS|lib|templates|css|js)$/'; diff --git a/core/lib/Drupal/Core/Utility/Site.php b/core/lib/Drupal/Core/Utility/Site.php new file mode 100644 index 0000000..4b81ad3 --- /dev/null +++ b/core/lib/Drupal/Core/Utility/Site.php @@ -0,0 +1,263 @@ +get('simpletest_conf_path'))) { + return FALSE; + } + + // Ensure that this is actually a simpletest request. We can't check this + // before settings.php is loaded. + if (!drupal_valid_test_ua()) { + return FALSE; + } + + // When the $simpletest_conf_path is set in a valid test request, return + // that path. + return $simpletest_conf_path; + } + + /** + * Finds the appropriate configuration directory for a given host and path. + * + * Finds a matching configuration directory file by stripping the website's + * hostname from left to right and pathname from right to left. By default, + * the directory must contain a 'settings.php' file for it to match. If the + * parameter $require_settings is set to FALSE, then a directory without a + * 'settings.php' file will match as well. The first configuration + * file found will be used and the remaining ones will be ignored. If no + * configuration file is found, returns a default value '$confdir/default'. See + * default.settings.php for examples on how the URL is converted to a directory. + * + * If a file named sites.php is present in the $confdir, it will be loaded + * prior to scanning for directories. That file can define aliases in an + * associative array named $sites. The array is written in the format + * '..' => 'directory'. As an 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 = array( + * '8080.www.drupal.org.mysite.test' => 'example.com', + * ); + * @endcode + * + * @param $http_host + * The hostname and optional port number, e.g. "www.example.com" or + * "www.example.com:8080". + * @param $script_name + * The part of the URL following the hostname, including the leading slash. + * @param $require_settings + * Defaults to TRUE. If TRUE, then only match directories with a + * 'settings.php' file. Otherwise match any directory. + * @param array $sites + * A multi-site mapping, as defined in settings.php. + * + * @return string + * The path of the matching configuration directory. + * + * @see default.settings.php + * @see \Drupal\Core\Utility\Site::determinePath() + */ + public static function getMultisitePath($http_host, $script_name, $require_settings, array $sites) { + $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. + if (isset($sites[$dir]) && file_exists(DRUPAL_ROOT . '/sites/' . $sites[$dir])) { + $dir = $sites[$dir]; + } + if (file_exists(DRUPAL_ROOT . '/sites/' . $dir . '/settings.php') || (!$require_settings && file_exists(DRUPAL_ROOT . '/sites/' . $dir))) { + return "sites/$dir"; + } + } + } + return 'sites/default'; + } + + + /** + * Sets the site path to a given path. + * + * @param string $path + * The relative path to the site configuration directory that will be set. + */ + public static function setPath($path) { + static::$custom = TRUE; + static::$path = $path; + } + + /** + * Resets the statically cached site path. + */ + public static function reset() { + static::$path = NULL; + static::$custom = FALSE; + // static::$root is not reset because it only depends on the location of + // this file on the file system which cannot change during a single request. + } + +} diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install index 960381c..c37fdd7 100644 --- a/core/modules/locale/locale.install +++ b/core/modules/locale/locale.install @@ -6,6 +6,7 @@ */ use Drupal\Core\Language\Language; +use Drupal\Core\Utility\Site; /** * Implements hook_install(). @@ -13,7 +14,7 @@ function locale_install() { // Create the interface translations directory and ensure it's writable. if (!$directory = \Drupal::config('locale.settings')->get('translation.path')) { - $directory = conf_path() . '/files/translations'; + $directory = Site::getPath('files/translations'); \Drupal::config('locale.settings')->set('translation.path', $directory)->save(); } file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 560afb1..6725cb7 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -19,6 +19,7 @@ use Drupal\Core\Language\Language; use Drupal\Core\StreamWrapper\PublicStream; use Drupal\Core\Utility\Error; +use Drupal\Core\Utility\Site; use Symfony\Component\HttpFoundation\Request; /** @@ -925,7 +926,7 @@ protected function prepareEnvironment() { // Save further contextual information. // Use the original files directory to avoid nesting it within an existing // simpletest directory if a test is executed within a test. - $this->originalFileDirectory = settings()->get('file_public_path', conf_path() . '/files'); + $this->originalFileDirectory = settings()->get('file_public_path', Site::getPath('files')); $this->originalProfile = drupal_get_profile(); $this->originalUser = isset($user) ? clone $user : NULL; @@ -1013,7 +1014,7 @@ protected function prepareConfigDirectories() { include_once DRUPAL_ROOT . '/core/includes/install.inc'; foreach (array(CONFIG_ACTIVE_DIRECTORY, CONFIG_STAGING_DIRECTORY) as $type) { // Assign the relative path to the global variable. - $path = conf_path() . '/files/simpletest/' . substr($this->databasePrefix, 10) . '/config_' . $type; + $path = Site::getPath('files/simpletest/' . substr($this->databasePrefix, 10) . '/config_' . $type); $GLOBALS['config_directories'][$type] = $path; // Ensure the directory can be created and is writeable. if (!install_ensure_config_directory($type)) { diff --git a/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php b/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php index 7fd19c5..2cef1a8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php @@ -6,6 +6,7 @@ */ namespace Drupal\system\Tests\File; +use Drupal\Core\Utility\Site; /** * Directory related tests. @@ -23,7 +24,7 @@ public static function getInfo() { * Test local directory handling functions. */ function testFileCheckLocalDirectoryHandling() { - $directory = conf_path() . '/files'; + $directory = Site::getPath('files'); // Check a new recursively created local directory for correct file system // permissions. diff --git a/core/modules/system/lib/Drupal/system/Tests/File/ReadOnlyStreamWrapperTest.php b/core/modules/system/lib/Drupal/system/Tests/File/ReadOnlyStreamWrapperTest.php index ef84796..ee0426a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/ReadOnlyStreamWrapperTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/ReadOnlyStreamWrapperTest.php @@ -6,6 +6,7 @@ */ namespace Drupal\system\Tests\File; +use Drupal\Core\Utility\Site; /** * Tests that files can not be written using ReadOnlyStreamWrapper functions. @@ -46,7 +47,7 @@ function tearDown() { function testWriteFunctions() { // Generate a test file $filename = $this->randomName(); - $filepath = conf_path() . '/files/' . $filename; + $filepath = Site::getPath('files/' . $filename); file_put_contents($filepath, $filename); // Generate a read-only stream wrapper instance @@ -89,7 +90,7 @@ function testWriteFunctions() { // Test the mkdir() function by attempting to create a directory. $dirname = $this->randomName(); - $dir = conf_path() . '/files/' . $dirname; + $dir = Site::getPath('files/' . $dirname); $readonlydir = $this->scheme . '://' . $dirname; $this->assertFalse(@drupal_mkdir($readonlydir, 0775, 0), 'Unable to create directory with read-only stream wrapper.'); // Create a temporary directory for testing purposes diff --git a/core/modules/system/lib/Drupal/system/Tests/System/SettingsRewriteTest.php b/core/modules/system/lib/Drupal/system/Tests/System/SettingsRewriteTest.php index 74c080d..6256f21 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/SettingsRewriteTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/SettingsRewriteTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\System; +use Drupal\Core\Utility\Site; use Drupal\simpletest\UnitTestBase; /** @@ -104,7 +105,7 @@ function testDrupalRewriteSettings() { ), ); foreach ($tests as $test) { - $filename = settings()->get('file_public_path', conf_path() . '/files') . '/mock_settings.php'; + $filename = settings()->get('file_public_path', Site::getPath('files')) . '/mock_settings.php'; file_put_contents(DRUPAL_ROOT . '/' . $filename, "assertEqual(file_get_contents(DRUPAL_ROOT . '/' . $filename), " $conf_path)); } @@ -327,9 +328,10 @@ function system_requirements($phase) { } else { // If we are installing Drupal, the settings.php file might not exist yet - // in the intended conf_path() directory, so don't require it. The - // conf_path() cache must also be reset in this case. - $directories[] = conf_path(FALSE, TRUE) . '/files'; + // in the intended site configuration directory, so don't require it. The + // static cache must also be reset in this case. + Site::reset(); + $directories[] = Site::getPath('files'); } if (!empty($conf['system.file']['path.private'])) { $directories[] = $conf['system.file']['path.private']; @@ -355,7 +357,7 @@ function system_requirements($phase) { $requirements['config directories'] = array( 'title' => t('Configuration directories'), 'value' => t('Not present'), - 'description' => t('Your %file file must define the $config_directories variable as an array containing the name of a directories in which configuration files can be written.', array('%file' => conf_path() . '/settings.php')), + 'description' => t('Your %file file must define the $config_directories variable as an array containing the name of a directories in which configuration files can be written.', array('%file' => Site::getPath('settings.php'))), 'severity' => REQUIREMENT_ERROR, ); } diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc index 19c0dc1..1ea7052 100644 --- a/core/modules/update/update.manager.inc +++ b/core/modules/update/update.manager.inc @@ -38,6 +38,7 @@ use Drupal\Core\Updater\Updater; use Drupal\Core\FileTransfer\Local; +use Drupal\Core\Utility\Site; use Symfony\Component\HttpFoundation\RedirectResponse; /** @@ -470,7 +471,7 @@ function update_manager_update_ready_form_submit($form, &$form_state) { // trying to install the code, there's no need to prompt for FTP/SSH // credentials. Instead, we instantiate a Drupal\Core\FileTransfer\Local and // invoke update_authorize_run_update() directly. - if (fileowner($project_real_location) == fileowner(conf_path())) { + if (fileowner($project_real_location) == fileowner(Site::getPath())) { module_load_include('inc', 'update', 'update.authorize'); $filetransfer = new Local(DRUPAL_ROOT); update_authorize_run_update($filetransfer, $updates); @@ -748,7 +749,7 @@ function update_manager_install_form_submit($form, &$form_state) { // trying to install the code, there's no need to prompt for FTP/SSH // credentials. Instead, we instantiate a Drupal\Core\FileTransfer\Local and // invoke update_authorize_run_install() directly. - if (fileowner($project_real_location) == fileowner(conf_path())) { + if (fileowner($project_real_location) == fileowner(Site::getPath())) { module_load_include('inc', 'update', 'update.authorize'); $filetransfer = new Local(DRUPAL_ROOT); call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments)); @@ -947,7 +948,7 @@ function update_manager_local_transfers_allowed() { // the configuration directory to determine if local transfers will be // allowed. $temporary_file = drupal_tempnam('temporary://', 'update_'); - $local_transfers_allowed = fileowner($temporary_file) === fileowner(conf_path()); + $local_transfers_allowed = fileowner($temporary_file) === fileowner(Site::getPath()); // Clean up. If this fails, we can ignore it (since this is just a temporary // file anyway). diff --git a/core/tests/Drupal/Tests/Component/Utility/PathTest.php b/core/tests/Drupal/Tests/Component/Utility/PathTest.php new file mode 100644 index 0000000..d54cd32 --- /dev/null +++ b/core/tests/Drupal/Tests/Component/Utility/PathTest.php @@ -0,0 +1,87 @@ + 'Path concatenation', + 'description' => 'Tests the path concatenation utility method', + 'group' => 'Common', + ); + } + + /** + * Tests \Drupal\Component\Utility\Path::suffix() + * + * @param string $path + * The path to pass to Path::suffix(). + * @param mixed $suffix + * The suffix to pass to Path::suffix(). + * @param string $expected + * The expected return result of Path::suffix() + * + * @see \Drupal\Component\Utility\Path::suffix() + * + * @dataProvider providerTestSuffix + */ + public function testSuffix($path, $suffix, $expected) { + $result = Path::suffix($path, $suffix); + $this->assertSame($expected, $result); + } + + /** + * Data provider for PathTest::testSuffix() + * + * @return array + * An array of arrays, where each inner array contains the path to pass to + * Path::suffix(), the suffix to pass to Path::suffix() and the expected + * return result of Path::suffix(). + */ + public function providerTestSuffix() { + $d = DIRECTORY_SEPARATOR; + return array( + array('', NULL, '.'), + array("relative{$d}path", NULL, "relative{$d}path"), + array("{$d}absolute{$d}path", NULL, "{$d}absolute{$d}path"), + array("relative{$d}path", '', "relative{$d}path"), + array("{$d}absolute{$d}path", '', "{$d}absolute{$d}path"), + array('', 'subdirectory', 'subdirectory'), + array("relative{$d}path", 'subdirectory', "relative{$d}path{$d}subdirectory"), + array("{$d}absolute{$d}path", 'subdirectory', "{$d}absolute{$d}path{$d}subdirectory"), + ); + } + + /** + * Tests that \Drupal\Component\Utility\Path::suffix() throws an exception. + */ + public function testSuffixException() { + try { + Path::suffix(NULL); + $this->assertTrue(FALSE); + } + catch (\InvalidArgumentException $e) { + $this->assertTrue(TRUE); + } + } + +} \ No newline at end of file diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php deleted file mode 100644 index 5a46b12..0000000 --- a/sites/default/default.settings.php +++ /dev/null @@ -1,662 +0,0 @@ - '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 master/slave replication, as Drupal may try to connect - * to a slave server when appropriate and if one is not available will simply - * fall back to the single master server. - * - * The general format for the $databases array is as follows: - * @code - * $databases['default']['default'] = $info_array; - * $databases['default']['slave'][] = $info_array; - * $databases['default']['slave'][] = $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 master database - * (the second level default). The second and third lines create an array - * of potential slave 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(); - -/** - * Salt for one-time login links and 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. If this variable is empty, a hash - * of the serialized database credentials will be used as a fallback salt. - * - * For enhanced security, you may set this variable to a value using the - * contents of a file outside your docroot that is never saved together - * with any backups of your Drupal files and database. - * - * Example: - * $drupal_hash_salt = file_get_contents('/home/example/salt.txt'); - * - */ -$drupal_hash_salt = ''; - -/** - * Location of the site configuration files. - * - * By default, Drupal configuration files are stored in a randomly named - * directory under the default public files path. On install the - * named directory is created in the default files directory. For enhanced - * security, you may set this variable to a location outside your docroot. - * - * @todo Flesh this out, provide more details, etc. - * - * 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 configuration that can not be saved in the configuration - * system because it is required too early during bootstrap like the database - * information. It is also used for configuration that is specific for a given - * environment like reverse proxy settings - * - * @see settings_get() - */ - -/** - * 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; - -/** - * 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). - */ -# $settings['twig_debug'] = TRUE; - -/** - * 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). - */ -# $settings['twig_auto_reload'] = TRUE; - -/** - * 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). - */ -# $settings['twig_cache'] = 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, Drupal uses Composer's ClassLoader, which is best for - * development, as it does not break when code is moved on the file - * system. It is possible, however, to wrap the class loader with a - * cached class loader solution for better performance, which is - * recommended for production sites. - * - * Examples: - * $settings['class_loader'] = 'apc'; - * $settings['class_loader'] = 'default'; - */ -# $settings['class_loader'] = 'apc'; - -/** - * 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; - -/** - * 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 enabled 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'; - -/** - * Enable access to rebuild.php. - * - * This setting can be enabled to allow Drupal's php and database cached - * storage to be cleared via the rebuild.php page. Access to this page can also - * be gained by generating a query string from rebuild_token_calculator.sh and - * using these parameters in a request to rebuild.php. - */ -# $settings['rebuild_access'] = TRUE; - -/** - * 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_environment_initialize() in core/includes/bootstrap.inc 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'; - -/** - * Variable overrides: - * - * To override specific entries in the 'variable' table 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. Any configuration setting from the 'variable' - * table can be given a new value. Note that any values you provide in - * these variable overrides will not be modifiable from the Drupal - * administration interface. - * - * The following overrides are examples: - * - site_name: Defines the site's name. - * - $conf['system.theme']['default']: Defines the default theme for this site. - * - anonymous: Defines the human-readable name of anonymous users. - * Remove the leading hash signs to enable. - */ -# $conf['system.site']['name'] = 'My Drupal site'; -# $conf['system.theme']['default'] = 'stark'; -# $conf['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. - */ -# $conf['system.performance']['css']['gzip'] = FALSE; -# $conf['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. - */ -#$conf['system.performance']['fast_404']['exclude_paths'] = '/\/(?:styles)\//'; -#$conf['system.performance']['fast_404']['paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; -#$conf['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 e-mails, 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(DRUPAL_ROOT . '/' . $conf_path . '/settings.local.php')) { -# include DRUPAL_ROOT . '/' . $conf_path . '/settings.local.php'; -# } diff --git a/sites/example.sites.php b/sites/example.sites.php deleted file mode 100644 index 2b00151..0000000 --- a/sites/example.sites.php +++ /dev/null @@ -1,55 +0,0 @@ -..' => 'directory'. As an - * example, to map http://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, http://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 http://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: http://www.drupal.org:8080/mysite/test/ - * $sites['8080.www.drupal.org.mysite.test'] = 'example.com'; - * @endcode - * - * @see default.settings.php - * @see conf_path() - * @see http://drupal.org/documentation/install/multi-site - */