summaryrefslogtreecommitdiffstatshomepage
path: root/core/includes/install.inc
diff options
context:
space:
mode:
Diffstat (limited to 'core/includes/install.inc')
-rw-r--r--core/includes/install.inc78
1 files changed, 39 insertions, 39 deletions
diff --git a/core/includes/install.inc b/core/includes/install.inc
index 6bb6c11a0d1..c5b93b58a65 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -96,7 +96,7 @@ function drupal_load_updates() {
function drupal_install_profile_distribution_name() {
// During installation, the profile information is stored in the global
// installation state (it might not be saved anywhere yet).
- $info = array();
+ $info = [];
if (drupal_installation_attempted()) {
global $install_state;
if (isset($install_state['profile_info'])) {
@@ -158,14 +158,14 @@ function drupal_detect_database_types() {
* An array of available database driver installer objects.
*/
function drupal_get_database_types() {
- $databases = array();
- $drivers = array();
+ $databases = [];
+ $drivers = [];
// The internal database driver name is any valid PHP identifier.
$mask = '/^' . DRUPAL_PHP_FUNCTION_PATTERN . '$/';
- $files = file_scan_directory(DRUPAL_ROOT . '/core/lib/Drupal/Core/Database/Driver', $mask, array('recurse' => FALSE));
+ $files = file_scan_directory(DRUPAL_ROOT . '/core/lib/Drupal/Core/Database/Driver', $mask, ['recurse' => FALSE]);
if (is_dir(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database')) {
- $files += file_scan_directory(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database/', $mask, array('recurse' => FALSE));
+ $files += file_scan_directory(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database/', $mask, ['recurse' => FALSE]);
}
foreach ($files as $file) {
if (file_exists($file->uri . '/Install/Tasks.php')) {
@@ -183,7 +183,7 @@ function drupal_get_database_types() {
if (isset($databases['mysql'])) {
$mysql_database = $databases['mysql'];
unset($databases['mysql']);
- $databases = array('mysql' => $mysql_database) + $databases;
+ $databases = ['mysql' => $mysql_database] + $databases;
}
return $databases;
@@ -213,13 +213,13 @@ function drupal_get_database_types() {
* $config_directories['sync'] = 'config_hash/sync'
* @endcode
*/
-function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
+function drupal_rewrite_settings($settings = [], $settings_file = NULL) {
if (!isset($settings_file)) {
$settings_file = \Drupal::service('site.path') . '/settings.php';
}
// Build list of setting names and insert the values into the global namespace.
- $variable_names = array();
- $settings_settings = array();
+ $variable_names = [];
+ $settings_settings = [];
foreach ($settings as $setting => $data) {
if ($setting != 'settings') {
_drupal_rewrite_settings_global($GLOBALS[$setting], $data);
@@ -248,7 +248,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
$value = $token;
}
// Do not operate on whitespace.
- if (!in_array($type, array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT))) {
+ if (!in_array($type, [T_WHITESPACE, T_COMMENT, T_DOC_COMMENT])) {
switch ($state) {
case 'default':
if ($type === T_VARIABLE && isset($variable_names[$value])) {
@@ -335,7 +335,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
// Write the new settings file.
if (file_put_contents($settings_file, $buffer) === FALSE) {
- throw new Exception(t('Failed to modify %settings. Verify the file permissions.', array('%settings' => $settings_file)));
+ throw new Exception(t('Failed to modify %settings. Verify the file permissions.', ['%settings' => $settings_file]));
}
else {
// In case any $settings variables were written, import them into the
@@ -352,7 +352,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
}
}
else {
- throw new Exception(t('Failed to open %settings. Verify the file permissions.', array('%settings' => $settings_file)));
+ throw new Exception(t('Failed to open %settings. Verify the file permissions.', ['%settings' => $settings_file]));
}
}
@@ -375,7 +375,7 @@ function _drupal_rewrite_settings_is_simple($type, $value) {
$is_integer = $type == T_LNUMBER;
$is_float = $type == T_DNUMBER;
$is_string = $type == T_CONSTANT_ENCAPSED_STRING;
- $is_boolean_or_null = $type == T_STRING && in_array(strtoupper($value), array('TRUE', 'FALSE', 'NULL'));
+ $is_boolean_or_null = $type == T_STRING && in_array(strtoupper($value), ['TRUE', 'FALSE', 'NULL']);
return $is_integer || $is_float || $is_string || $is_boolean_or_null;
}
@@ -504,10 +504,10 @@ function drupal_install_config_directories() {
// Bail out using a similar error message as in system_requirements().
if (!file_prepare_directory($config_directories[CONFIG_SYNC_DIRECTORY], FILE_CREATE_DIRECTORY)
&& !file_exists($config_directories[CONFIG_SYNC_DIRECTORY])) {
- throw new Exception(t('The directory %directory could not be created. To proceed with the installation, either create the directory or ensure that the installer has the permissions to create it automatically. For more information, see the <a href=":handbook_url">online handbook</a>.', array(
+ throw new Exception(t('The directory %directory could not be created. To proceed with the installation, either create the directory or ensure that the installer has the permissions to create it automatically. For more information, see the <a href=":handbook_url">online handbook</a>.', [
'%directory' => config_get_config_directory(CONFIG_SYNC_DIRECTORY),
':handbook_url' => 'https://www.drupal.org/server-permissions',
- )));
+ ]));
}
elseif (is_writable($config_directories[CONFIG_SYNC_DIRECTORY])) {
// Put a README.txt into the sync config directory. This is required so that
@@ -560,7 +560,7 @@ function drupal_verify_profile($install_state) {
// Get the list of available modules for the selected installation profile.
$listing = new ExtensionDiscovery(\Drupal::root());
- $present_modules = array();
+ $present_modules = [];
foreach ($listing->scan('module') as $present_module) {
$present_modules[] = $present_module->getName();
}
@@ -572,7 +572,7 @@ function drupal_verify_profile($install_state) {
// Verify that all of the profile's required modules are present.
$missing_modules = array_diff($info['dependencies'], $present_modules);
- $requirements = array();
+ $requirements = [];
if ($missing_modules) {
$build = [
@@ -581,16 +581,16 @@ function drupal_verify_profile($install_state) {
];
foreach ($missing_modules as $module) {
- $build['#items'][] = array('#markup' => '<span class="admin-missing">' . Unicode::ucfirst($module) . '</span>');
+ $build['#items'][] = ['#markup' => '<span class="admin-missing">' . Unicode::ucfirst($module) . '</span>'];
}
$modules_list = \Drupal::service('renderer')->renderPlain($build);
- $requirements['required_modules'] = array(
+ $requirements['required_modules'] = [
'title' => t('Required modules'),
'value' => t('Required modules not found.'),
'severity' => REQUIREMENT_ERROR,
- 'description' => t('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as <em>/modules</em>. Missing modules: @modules', array('@modules' => $modules_list)),
- );
+ 'description' => t('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as <em>/modules</em>. Missing modules: @modules', ['@modules' => $modules_list]),
+ ];
}
return $requirements;
}
@@ -628,7 +628,7 @@ function drupal_install_system($install_state) {
->save();
// Install System module and rebuild the newly available routes.
- $kernel->getContainer()->get('module_installer')->install(array('system'), FALSE);
+ $kernel->getContainer()->get('module_installer')->install(['system'], FALSE);
\Drupal::service('router.builder')->rebuild();
// Ensure default language is saved.
@@ -669,7 +669,7 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
// Verify file permissions.
if (isset($mask)) {
- $masks = array(FILE_EXIST, FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
+ $masks = [FILE_EXIST, FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE];
foreach ($masks as $current_mask) {
if ($mask & $current_mask) {
switch ($current_mask) {
@@ -735,7 +735,7 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
*/
function drupal_install_mkdir($file, $mask, $message = TRUE) {
$mod = 0;
- $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
+ $masks = [FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE];
foreach ($masks as $m) {
if ($mask & $m) {
switch ($m) {
@@ -789,7 +789,7 @@ function drupal_install_fix_file($file, $mask, $message = TRUE) {
}
$mod = fileperms($file) & 0777;
- $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
+ $masks = [FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE];
// FILE_READABLE, FILE_WRITABLE, and FILE_EXECUTABLE permission strings
// can theoretically be 0400, 0200, and 0100 respectively, but to be safe
@@ -851,10 +851,10 @@ function drupal_install_fix_file($file, $mask, $message = TRUE) {
*/
function install_goto($path) {
global $base_url;
- $headers = array(
+ $headers = [
// Not a permanent redirect.
'Cache-Control' => 'no-cache',
- );
+ ];
$response = new RedirectResponse($base_url . '/' . $path, 302, $headers);
$response->send();
}
@@ -886,7 +886,7 @@ function install_goto($path) {
* @see drupal_requirements_url()
* @see Drupal\Component\Utility\UrlHelper::filterBadProtocol()
*/
-function drupal_current_script_url($query = array()) {
+function drupal_current_script_url($query = []) {
$uri = $_SERVER['SCRIPT_NAME'];
$query = array_merge(UrlHelper::filterQueryParameters(\Drupal::request()->query->all()), $query);
if (!empty($query)) {
@@ -916,7 +916,7 @@ function drupal_current_script_url($query = array()) {
* @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol()
*/
function drupal_requirements_url($severity) {
- $query = array();
+ $query = [];
// If there are no errors, only warnings, append 'continue=1' to the URL so
// the user can bypass this screen on the next page load.
if ($severity == REQUIREMENT_WARNING) {
@@ -937,7 +937,7 @@ function drupal_requirements_url($severity) {
function drupal_check_profile($profile) {
$info = install_profile_info($profile);
// Collect requirement testing results.
- $requirements = array();
+ $requirements = [];
// Performs an ExtensionDiscovery scan as the system module is unavailable and
// we don't yet know where all the modules are located.
// @todo Remove as part of https://www.drupal.org/node/2186491
@@ -1000,14 +1000,14 @@ function drupal_requirements_severity(&$requirements) {
function drupal_check_module($module) {
module_load_install($module);
// Check requirements
- $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', array('install'));
+ $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', ['install']);
if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) {
// Print any error messages
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
$message = $requirement['description'];
if (isset($requirement['value']) && $requirement['value']) {
- $message = t('@requirements_message (Currently using @item version @version)', array('@requirements_message' => $requirement['description'], '@item' => $requirement['title'], '@version' => $requirement['value']));
+ $message = t('@requirements_message (Currently using @item version @version)', ['@requirements_message' => $requirement['description'], '@item' => $requirement['title'], '@version' => $requirement['value']]);
}
drupal_set_message($message, 'error');
}
@@ -1066,27 +1066,27 @@ function drupal_check_module($module) {
* The info array.
*/
function install_profile_info($profile, $langcode = 'en') {
- $cache = &drupal_static(__FUNCTION__, array());
+ $cache = &drupal_static(__FUNCTION__, []);
if (!isset($cache[$profile][$langcode])) {
// Set defaults for module info.
- $defaults = array(
- 'dependencies' => array(),
- 'themes' => array('stark'),
+ $defaults = [
+ 'dependencies' => [],
+ 'themes' => ['stark'],
'description' => '',
'version' => NULL,
'hidden' => FALSE,
'php' => DRUPAL_MINIMUM_PHP,
- );
+ ];
$profile_file = drupal_get_path('profile', $profile) . "/$profile.info.yml";
$info = \Drupal::service('info_parser')->parse($profile_file);
$info += $defaults;
// drupal_required_modules() includes the current profile as a dependency.
// Remove that dependency, since a module cannot depend on itself.
- $required = array_diff(drupal_required_modules(), array($profile));
+ $required = array_diff(drupal_required_modules(), [$profile]);
- $locale = !empty($langcode) && $langcode != 'en' ? array('locale') : array();
+ $locale = !empty($langcode) && $langcode != 'en' ? ['locale'] : [];
$info['dependencies'] = array_unique(array_merge($required, $info['dependencies'], $locale));