Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -50,7 +50,7 @@ function _batch_page(Request $request) {
// Register database update for the end of processing.
drupal_register_shutdown_function('_batch_shutdown');
$build = array();
$build = [];
// Add batch-specific libraries.
foreach ($batch['sets'] as $batch_set) {
@ -94,7 +94,7 @@ function _batch_do() {
// Perform actual processing.
list($percentage, $message, $label) = _batch_process();
return new JsonResponse(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message, 'label' => $label));
return new JsonResponse(['status' => TRUE, 'percentage' => $percentage, 'message' => $message, 'label' => $label]);
}
/**
@ -130,9 +130,9 @@ function _batch_progress_page() {
// it. While this causes invalid HTML, the same would be true if we didn't,
// as content is not allowed to appear after </html> anyway.
$bare_html_page_renderer = \Drupal::service('bare_html_page_renderer');
$response = $bare_html_page_renderer->renderBarePage(['#markup' => $fallback], $current_set['title'], 'maintenance_page', array(
$response = $bare_html_page_renderer->renderBarePage(['#markup' => $fallback], $current_set['title'], 'maintenance_page', [
'#show_messages' => FALSE,
));
]);
// Just use the content of the response.
$fallback = $response->getContent();
@ -159,26 +159,26 @@ function _batch_progress_page() {
$url = $batch['url']->toString(TRUE)->getGeneratedUrl();
$build = array(
$build = [
'#theme' => 'progress_bar',
'#percent' => $percentage,
'#message' => array('#markup' => $message),
'#message' => ['#markup' => $message],
'#label' => $label,
'#attached' => array(
'html_head' => array(
array(
array(
'#attached' => [
'html_head' => [
[
[
// Redirect through a 'Refresh' meta tag if JavaScript is disabled.
'#tag' => 'meta',
'#noscript' => TRUE,
'#attributes' => array(
'#attributes' => [
'http-equiv' => 'Refresh',
'content' => '0; URL=' . $url,
),
),
],
],
'batch_progress_meta_refresh',
),
),
],
],
// Adds JavaScript code and settings for clients where JavaScript is enabled.
'drupalSettings' => [
'batch' => [
@ -187,11 +187,11 @@ function _batch_progress_page() {
'uri' => $url,
],
],
'library' => array(
'library' => [
'core/drupal.batch',
),
),
);
],
],
];
return $build;
}
@ -243,13 +243,13 @@ function _batch_process() {
list($callback, $args) = $item->data;
// Build the 'context' array and execute the function call.
$batch_context = array(
$batch_context = [
'sandbox' => &$current_set['sandbox'],
'results' => &$current_set['results'],
'finished' => &$finished,
'message' => &$task_message,
);
call_user_func_array($callback, array_merge($args, array(&$batch_context)));
];
call_user_func_array($callback, array_merge($args, [&$batch_context]));
if ($finished >= 1) {
// Make sure this step is not counted twice when computing $current.
@ -257,7 +257,7 @@ function _batch_process() {
// Remove the processed operation and clear the sandbox.
$queue->deleteItem($item);
$current_set['count']--;
$current_set['sandbox'] = array();
$current_set['sandbox'] = [];
}
}
@ -312,7 +312,7 @@ function _batch_process() {
$current = $total - $remaining + $finished;
$percentage = _batch_api_percentage($total, $current);
$elapsed = isset($current_set['elapsed']) ? $current_set['elapsed'] : 0;
$values = array(
$values = [
'@remaining' => $remaining,
'@total' => $total,
'@current' => floor($current),
@ -320,13 +320,13 @@ function _batch_process() {
'@elapsed' => \Drupal::service('date.formatter')->formatInterval($elapsed / 1000),
// If possible, estimate remaining processing time.
'@estimate' => ($current > 0) ? \Drupal::service('date.formatter')->formatInterval(($elapsed * ($total - $current) / $current) / 1000) : '-',
);
];
$message = strtr($progress_message, $values);
if (!empty($task_message)) {
$label = $task_message;
}
return array($percentage, $message, $label);
return [$percentage, $message, $label];
}
else {
// If we are not in progressive mode, the entire batch has been processed.
@ -385,7 +385,7 @@ function _batch_next_set() {
// We use our stored copies of $form and $form_state to account for
// possible alterations by previous form submit handlers.
$complete_form = &$batch['form_state']->getCompleteForm();
call_user_func_array($callback, array(&$complete_form, &$batch['form_state']));
call_user_func_array($callback, [&$complete_form, &$batch['form_state']]);
}
return TRUE;
}
@ -411,7 +411,7 @@ function _batch_finished() {
if (is_callable($batch_set['finished'])) {
$queue = _batch_queue($batch_set);
$operations = $queue->getAllItems();
$batch_set_result = call_user_func_array($batch_set['finished'], array($batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date.formatter')->formatInterval($batch_set['elapsed'] / 1000)));
$batch_set_result = call_user_func_array($batch_set['finished'], [$batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date.formatter')->formatInterval($batch_set['elapsed'] / 1000)]);
// If a batch 'finished' callback requested a redirect after the batch
// is complete, save that for later use. If more than one batch set
// returned a redirect, the last one is used.
@ -491,17 +491,13 @@ function _batch_finished() {
$_SESSION['batch_form_state'] = $_batch['form_state'];
}
$callback = $_batch['redirect_callback'];
/** @var \Drupal\Core\Url $source_url */
$source_url = $_batch['source_url'];
$_batch['source_url']->mergeOptions(['query' => ['op' => 'finish', 'id' => $_batch['id']]]);
if (is_callable($callback)) {
$callback($_batch['source_url'], array('query' => array('op' => 'finish', 'id' => $_batch['id'])));
$callback($_batch['source_url'], $_batch['source_url']->getOption('query'));
}
elseif ($callback === NULL) {
// Default to RedirectResponse objects when nothing specified.
$url = $source_url
->setAbsolute()
->setOption('query', ['op' => 'finish', 'id' => $_batch['id']]);
return new RedirectResponse($url->toString());
return new RedirectResponse($_batch['source_url']->setAbsolute()->toString());
}
}
}

View file

@ -9,6 +9,7 @@ use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\BootstrapConfigStorageFactory;
use Drupal\Core\Logger\RfcLogLevel;
use Drupal\Core\Render\Markup;
use Drupal\Component\Render\MarkupInterface;
@ -84,6 +85,9 @@ const DRUPAL_EXTENSION_NAME_MAX_LENGTH = 50;
*
* @see http://php.net/manual/reserved.variables.server.php
* @see http://php.net/manual/function.time.php
*
* @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0.
* Use \Drupal::time()->getRequestTime();
*/
define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']);
@ -193,7 +197,7 @@ function config_get_config_directory($type) {
function drupal_get_filename($type, $name, $filename = NULL) {
// The location of files will not change during the request, so do not use
// drupal_static().
static $files = array();
static $files = [];
// Type 'core' only exists to simplify application-level logic; it always maps
// to the /core directory, whereas $name is ignored. It is only requested via
@ -209,7 +213,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
$type = 'module';
}
if (!isset($files[$type])) {
$files[$type] = array();
$files[$type] = [];
}
if (isset($filename)) {
@ -229,11 +233,11 @@ function drupal_get_filename($type, $name, $filename = NULL) {
// system_rebuild_module_data() and
// \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData().
if (!isset($files[$type][$name]) && \Drupal::hasService('state')) {
$files[$type] += \Drupal::state()->get('system.' . $type . '.files', array());
$files[$type] += \Drupal::state()->get('system.' . $type . '.files', []);
}
// If still unknown, create a user-level error message.
if (!isset($files[$type][$name])) {
trigger_error(SafeMarkup::format('The following @type is missing from the file system: @name', array('@type' => $type, '@name' => $name)), E_USER_WARNING);
trigger_error(SafeMarkup::format('The following @type is missing from the file system: @name', ['@type' => $type, '@name' => $name]), E_USER_WARNING);
}
}
@ -297,7 +301,7 @@ function drupal_get_path($type, $name) {
*
* @ingroup sanitization
*/
function t($string, array $args = array(), array $options = array()) {
function t($string, array $args = [], array $options = []) {
return new TranslatableMarkup($string, $args, $options);
}
@ -372,7 +376,7 @@ function drupal_validate_utf8($text) {
*
* @see \Drupal\Core\Utility\Error::decodeException()
*/
function watchdog_exception($type, Exception $exception, $message = NULL, $variables = array(), $severity = RfcLogLevel::ERROR, $link = NULL) {
function watchdog_exception($type, Exception $exception, $message = NULL, $variables = [], $severity = RfcLogLevel::ERROR, $link = NULL) {
// Use a default value if $message is not set.
if (empty($message)) {
@ -443,7 +447,7 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia
function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) {
if (isset($message)) {
if (!isset($_SESSION['messages'][$type])) {
$_SESSION['messages'][$type] = array();
$_SESSION['messages'][$type] = [];
}
// Convert strings which are safe to the simplest Markup objects.
@ -497,7 +501,7 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
unset($_SESSION['messages'][$type]);
}
if (isset($messages[$type])) {
return array($type => $messages[$type]);
return [$type => $messages[$type]];
}
}
else {
@ -507,7 +511,7 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
return $messages;
}
}
return array();
return [];
}
/**
@ -724,12 +728,20 @@ function drupal_installation_attempted() {
* When this function is called during Drupal's initial installation process,
* the name of the profile that's about to be installed is stored in the global
* installation state. At all other times, the "install_profile" setting will be
* available in settings.php.
* available in container as a parameter.
*
* @return string|null $profile
* @return string|null
* The name of the installation profile or NULL if no installation profile is
* currently active. This is the case for example during the first steps of
* the installer or during unit tests.
*
* @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0.
* Use the install_profile container parameter or \Drupal::installProfile()
* instead. If you are accessing the value before it is written to
* configuration during the installer use the $install_state global. If you
* need to access the value before container is available you can use
* BootstrapConfigStorageFactory to load the value directly from
* configuration.
*/
function drupal_get_profile() {
global $install_state;
@ -744,8 +756,18 @@ function drupal_get_profile() {
}
}
else {
// Fall back to NULL, if there is no 'install_profile' setting.
$profile = Settings::get('install_profile');
if (\Drupal::hasContainer()) {
$profile = \Drupal::installProfile();
}
else {
$profile = BootstrapConfigStorageFactory::getDatabaseStorage()->read('core.extension')['profile'];
}
// A BC layer just in in case this only exists in Settings. Introduced in
// Drupal 8.3.x and will be removed before Drupal 9.0.0.
if (empty($profile)) {
$profile = Settings::get('install_profile');
}
}
return $profile;
@ -877,7 +899,7 @@ function drupal_classloader_register($name, $path) {
* @see drupal_static_reset()
*/
function &drupal_static($name, $default_value = NULL, $reset = FALSE) {
static $data = array(), $default = array();
static $data = [], $default = [];
// First check if dealing with a previously defined static variable.
if (isset($data[$name]) || array_key_exists($name, $data)) {
// Non-NULL $name and both $data[$name] and $default[$name] statics exist.
@ -956,7 +978,7 @@ function drupal_placeholder($text) {
function &drupal_register_shutdown_function($callback = NULL) {
// We cannot use drupal_static() here because the static cache is reset during
// batch processing, which breaks batch handling.
static $callbacks = array();
static $callbacks = [];
if (isset($callback)) {
// Only register the internal shutdown function once.
@ -967,7 +989,7 @@ function &drupal_register_shutdown_function($callback = NULL) {
// Remove $callback from the arguments.
unset($args[0]);
// Save callback and arguments
$callbacks[] = array('callback' => $callback, 'arguments' => $args);
$callbacks[] = ['callback' => $callback, 'arguments' => $args];
}
return $callbacks;
}

View file

@ -249,7 +249,7 @@ function check_url($uri) {
*/
function format_size($size, $langcode = NULL) {
if ($size < Bytes::KILOBYTE) {
return \Drupal::translation()->formatPlural($size, '1 byte', '@count bytes', array(), array('langcode' => $langcode));
return \Drupal::translation()->formatPlural($size, '1 byte', '@count bytes', [], ['langcode' => $langcode]);
}
else {
$size = $size / Bytes::KILOBYTE; // Convert bytes to kilobytes.
@ -352,7 +352,7 @@ function date_iso8601($date) {
* A ; separated string ready for insertion in a HTTP header. No escaping is
* performed for HTML entities, so this string is not safe to be printed.
*/
function drupal_http_header_attributes(array $attributes = array()) {
function drupal_http_header_attributes(array $attributes = []) {
foreach ($attributes as $attribute => &$data) {
if (is_array($data)) {
$data = implode(' ', $data);
@ -433,18 +433,18 @@ function drupal_clear_css_cache() {
* @see hook_js_alter()
*/
function drupal_js_defaults($data = NULL) {
return array(
return [
'type' => 'file',
'group' => JS_DEFAULT,
'weight' => 0,
'scope' => 'header',
'cache' => TRUE,
'preprocess' => TRUE,
'attributes' => array(),
'attributes' => [],
'version' => NULL,
'data' => $data,
'browsers' => array(),
);
'browsers' => [],
];
}
/**
@ -704,12 +704,12 @@ function drupal_process_states(&$elements) {
*/
function drupal_attach_tabledrag(&$element, array $options) {
// Add default values to elements.
$options = $options + array(
$options = $options + [
'subgroup' => NULL,
'source' => NULL,
'hidden' => TRUE,
'limit' => 0
);
];
$group = $options['group'];
@ -719,14 +719,14 @@ function drupal_attach_tabledrag(&$element, array $options) {
// If a subgroup or source isn't set, assume it is the same as the group.
$target = isset($options['subgroup']) ? $options['subgroup'] : $group;
$source = isset($options['source']) ? $options['source'] : $target;
$element['#attached']['drupalSettings']['tableDrag'][$options['table_id']][$group][$tabledrag_id] = array(
$element['#attached']['drupalSettings']['tableDrag'][$options['table_id']][$group][$tabledrag_id] = [
'target' => $target,
'source' => $source,
'relationship' => $options['relationship'],
'action' => $options['action'],
'hidden' => $options['hidden'],
'limit' => $options['limit'],
);
];
$element['#attached']['library'][] = 'core/drupal.tabledrag';
}
@ -827,7 +827,7 @@ function drupal_pre_render_link($element) {
* properties of the parent are used.
*/
function drupal_pre_render_links($element) {
$element += array('#links' => array(), '#attached' => array());
$element += ['#links' => [], '#attached' => []];
foreach (Element::children($element) as $key) {
$child = &$element[$key];
// If the child has links which have not been printed yet and the user has
@ -1115,7 +1115,7 @@ function drupal_flush_all_caches() {
// Rebuild and reboot a new kernel. A simple DrupalKernel reboot is not
// sufficient, since the list of enabled modules might have been adjusted
// above due to changed code.
$files = array();
$files = [];
foreach ($module_data as $name => $extension) {
if ($extension->status) {
$files[$name] = $extension;
@ -1217,7 +1217,7 @@ function drupal_check_incompatibility($v, $current_version) {
* validation system.
*/
function archiver_get_extensions() {
$valid_extensions = array();
$valid_extensions = [];
foreach (\Drupal::service('plugin.manager.archiver')->getDefinitions() as $archive) {
foreach ($archive['extensions'] as $extension) {
foreach (explode('.', $extension) as $part) {
@ -1246,9 +1246,9 @@ function archiver_get_archiver($file) {
// Archivers can only work on local paths
$filepath = drupal_realpath($file);
if (!is_file($filepath)) {
throw new Exception(t('Archivers can only operate on local files: %file not supported', array('%file' => $file)));
throw new Exception(t('Archivers can only operate on local files: %file not supported', ['%file' => $file]));
}
return \Drupal::service('plugin.manager.archiver')->getInstance(array('filepath' => $filepath));
return \Drupal::service('plugin.manager.archiver')->getInstance(['filepath' => $filepath]);
}
/**
@ -1270,7 +1270,7 @@ function drupal_get_updaters() {
if (!isset($updaters)) {
$updaters = \Drupal::moduleHandler()->invokeAll('updater_info');
\Drupal::moduleHandler()->alter('updater_info', $updaters);
uasort($updaters, array(SortArray::class, 'sortByWeightElement'));
uasort($updaters, [SortArray::class, 'sortByWeightElement']);
}
return $updaters;
}
@ -1290,7 +1290,7 @@ function drupal_get_filetransfer_info() {
if (!isset($info)) {
$info = \Drupal::moduleHandler()->invokeAll('filetransfer_info');
\Drupal::moduleHandler()->alter('filetransfer_info', $info);
uasort($info, array(SortArray::class, 'sortByWeightElement'));
uasort($info, [SortArray::class, 'sortByWeightElement']);
}
return $info;
}

View file

@ -53,7 +53,7 @@ use Drupal\Core\Site\Settings;
* @see \Drupal\Core\Database\Connection::query()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
function db_query($query, array $args = array(), array $options = array()) {
function db_query($query, array $args = [], array $options = []) {
if (empty($options['target'])) {
$options['target'] = 'default';
}
@ -91,7 +91,7 @@ function db_query($query, array $args = array(), array $options = array()) {
* @see \Drupal\Core\Database\Connection::queryRange()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
function db_query_range($query, $from, $count, array $args = array(), array $options = array()) {
function db_query_range($query, $from, $count, array $args = [], array $options = []) {
if (empty($options['target'])) {
$options['target'] = 'default';
}
@ -127,7 +127,7 @@ function db_query_range($query, $from, $count, array $args = array(), array $opt
* @see \Drupal\Core\Database\Connection::queryTemporary()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
function db_query_temporary($query, array $args = array(), array $options = array()) {
function db_query_temporary($query, array $args = [], array $options = []) {
if (empty($options['target'])) {
$options['target'] = 'default';
}
@ -154,7 +154,7 @@ function db_query_temporary($query, array $args = array(), array $options = arra
* @see \Drupal\Core\Database\Connection::insert()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
function db_insert($table, array $options = array()) {
function db_insert($table, array $options = []) {
if (empty($options['target']) || $options['target'] == 'replica') {
$options['target'] = 'default';
}
@ -180,7 +180,7 @@ function db_insert($table, array $options = array()) {
* @see \Drupal\Core\Database\Connection::merge()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
function db_merge($table, array $options = array()) {
function db_merge($table, array $options = []) {
if (empty($options['target']) || $options['target'] == 'replica') {
$options['target'] = 'default';
}
@ -206,7 +206,7 @@ function db_merge($table, array $options = array()) {
* @see \Drupal\Core\Database\Connection::update()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
function db_update($table, array $options = array()) {
function db_update($table, array $options = []) {
if (empty($options['target']) || $options['target'] == 'replica') {
$options['target'] = 'default';
}
@ -232,7 +232,7 @@ function db_update($table, array $options = array()) {
* @see \Drupal\Core\Database\Connection::delete()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
function db_delete($table, array $options = array()) {
function db_delete($table, array $options = []) {
if (empty($options['target']) || $options['target'] == 'replica') {
$options['target'] = 'default';
}
@ -258,7 +258,7 @@ function db_delete($table, array $options = array()) {
* @see \Drupal\Core\Database\Connection::truncate()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
function db_truncate($table, array $options = array()) {
function db_truncate($table, array $options = []) {
if (empty($options['target']) || $options['target'] == 'replica') {
$options['target'] = 'default';
}
@ -288,7 +288,7 @@ function db_truncate($table, array $options = array()) {
* @see \Drupal\Core\Database\Connection::select()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
function db_select($table, $alias = NULL, array $options = array()) {
function db_select($table, $alias = NULL, array $options = []) {
if (empty($options['target'])) {
$options['target'] = 'default';
}
@ -315,7 +315,7 @@ function db_select($table, $alias = NULL, array $options = array()) {
* @see \Drupal\Core\Database\Connection::startTransaction()
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
function db_transaction($name = NULL, array $options = array()) {
function db_transaction($name = NULL, array $options = []) {
if (empty($options['target'])) {
$options['target'] = 'default';
}
@ -451,7 +451,7 @@ function db_driver() {
*
* @see \Drupal\Core\Database\Database::closeConnection()
*/
function db_close(array $options = array()) {
function db_close(array $options = []) {
if (empty($options['target'])) {
$options['target'] = NULL;
}
@ -752,7 +752,7 @@ function db_drop_table($table) {
* @see \Drupal\Core\Database\Schema::addField()
* @see db_change_field()
*/
function db_add_field($table, $field, $spec, $keys_new = array()) {
function db_add_field($table, $field, $spec, $keys_new = []) {
return Database::getConnection()->schema()->addField($table, $field, $spec, $keys_new);
}
@ -1020,7 +1020,7 @@ function db_drop_index($table, $name) {
*
* @see \Drupal\Core\Database\Schema::changeField()
*/
function db_change_field($table, $field, $field_new, $spec, $keys_new = array()) {
function db_change_field($table, $field, $field_new, $spec, $keys_new = []) {
return Database::getConnection()->schema()->changeField($table, $field, $field_new, $spec, $keys_new);
}

View file

@ -80,7 +80,7 @@ function entity_get_bundles($entity_type = NULL) {
function entity_load($entity_type, $id, $reset = FALSE) {
$controller = \Drupal::entityManager()->getStorage($entity_type);
if ($reset) {
$controller->resetCache(array($id));
$controller->resetCache([$id]);
}
return $controller->load($id);
}
@ -305,7 +305,7 @@ function entity_delete_multiple($entity_type, array $ids) {
* @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage()
* @see \Drupal\Core\Entity\EntityStorageInterface::create()
*/
function entity_create($entity_type, array $values = array()) {
function entity_create($entity_type, array $values = []) {
return \Drupal::entityManager()
->getStorage($entity_type)
->create($values);
@ -483,12 +483,12 @@ function entity_get_display($entity_type, $bundle, $view_mode) {
// configuration entries are only created when a display object is explicitly
// configured and saved.
if (!$display) {
$display = EntityViewDisplay::create(array(
$display = EntityViewDisplay::create([
'targetEntityType' => $entity_type,
'bundle' => $bundle,
'mode' => $view_mode,
'status' => TRUE,
));
]);
}
return $display;
@ -514,7 +514,7 @@ function entity_get_display($entity_type, $bundle, $view_mode) {
* 'weight' => 1,
* ))
* ->setComponent('field_image', array(
* 'type' => 'hidden',
* 'region' => 'hidden',
* ))
* ->save();
* @endcode
@ -563,12 +563,12 @@ function entity_get_form_display($entity_type, $bundle, $form_mode) {
// configuration entries are only created when an entity form display is
// explicitly configured and saved.
if (!$entity_form_display) {
$entity_form_display = EntityFormDisplay::create(array(
$entity_form_display = EntityFormDisplay::create([
'targetEntityType' => $entity_type,
'bundle' => $bundle,
'mode' => $form_mode,
'status' => TRUE,
));
]);
}
return $entity_form_display;

View file

@ -21,23 +21,23 @@ use Symfony\Component\HttpFoundation\Response;
* @ingroup logging_severity_levels
*/
function drupal_error_levels() {
$types = array(
E_ERROR => array('Error', RfcLogLevel::ERROR),
E_WARNING => array('Warning', RfcLogLevel::WARNING),
E_PARSE => array('Parse error', RfcLogLevel::ERROR),
E_NOTICE => array('Notice', RfcLogLevel::NOTICE),
E_CORE_ERROR => array('Core error', RfcLogLevel::ERROR),
E_CORE_WARNING => array('Core warning', RfcLogLevel::WARNING),
E_COMPILE_ERROR => array('Compile error', RfcLogLevel::ERROR),
E_COMPILE_WARNING => array('Compile warning', RfcLogLevel::WARNING),
E_USER_ERROR => array('User error', RfcLogLevel::ERROR),
E_USER_WARNING => array('User warning', RfcLogLevel::WARNING),
E_USER_NOTICE => array('User notice', RfcLogLevel::NOTICE),
E_STRICT => array('Strict warning', RfcLogLevel::DEBUG),
E_RECOVERABLE_ERROR => array('Recoverable fatal error', RfcLogLevel::ERROR),
E_DEPRECATED => array('Deprecated function', RfcLogLevel::DEBUG),
E_USER_DEPRECATED => array('User deprecated function', RfcLogLevel::DEBUG),
);
$types = [
E_ERROR => ['Error', RfcLogLevel::ERROR],
E_WARNING => ['Warning', RfcLogLevel::WARNING],
E_PARSE => ['Parse error', RfcLogLevel::ERROR],
E_NOTICE => ['Notice', RfcLogLevel::NOTICE],
E_CORE_ERROR => ['Core error', RfcLogLevel::ERROR],
E_CORE_WARNING => ['Core warning', RfcLogLevel::WARNING],
E_COMPILE_ERROR => ['Compile error', RfcLogLevel::ERROR],
E_COMPILE_WARNING => ['Compile warning', RfcLogLevel::WARNING],
E_USER_ERROR => ['User error', RfcLogLevel::ERROR],
E_USER_WARNING => ['User warning', RfcLogLevel::WARNING],
E_USER_NOTICE => ['User notice', RfcLogLevel::NOTICE],
E_STRICT => ['Strict warning', RfcLogLevel::DEBUG],
E_RECOVERABLE_ERROR => ['Recoverable fatal error', RfcLogLevel::ERROR],
E_DEPRECATED => ['Deprecated function', RfcLogLevel::DEBUG],
E_USER_DEPRECATED => ['User deprecated function', RfcLogLevel::DEBUG],
];
return $types;
}
@ -70,7 +70,7 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
// in PHP, we allow them to trigger a fatal error by emitting a user error
// using trigger_error().
$to_string = $error_level == E_USER_ERROR && substr($caller['function'], -strlen('__toString()')) == '__toString()';
_drupal_log_error(array(
_drupal_log_error([
'%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error',
// The standard PHP error handler considers that the error messages
// are HTML. We mimick this behavior here.
@ -81,7 +81,7 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c
'severity_level' => $severity_level,
'backtrace' => $backtrace,
'@backtrace_string' => (new \Exception())->getTraceAsString(),
), $recoverable || $to_string);
], $recoverable || $to_string);
}
}
@ -139,15 +139,15 @@ function _drupal_log_error($error, $fatal = FALSE) {
// $number does not use drupal_static as it should not be reset
// as it uniquely identifies each PHP error.
static $number = 0;
$assertion = array(
$assertion = [
$error['@message'],
$error['%type'],
array(
[
'function' => $error['%function'],
'file' => $error['%file'],
'line' => $error['%line'],
),
);
],
];
// For non-fatal errors (e.g. PHP notices) _drupal_log_error can be called
// multiple times per request. In that case the response is typically
// generated outside of the error handler, e.g., in a controller. As a
@ -257,10 +257,10 @@ function _drupal_log_error($error, $fatal = FALSE) {
if ($is_installer) {
// install_display_output() prints the output and ends script execution.
$output = array(
$output = [
'#title' => 'Error',
'#markup' => $message,
);
];
install_display_output($output, $GLOBALS['install_state'], $response->headers->all());
exit;
}

View file

@ -367,7 +367,7 @@ function file_save_htaccess($directory, $private = TRUE, $force_overwrite = FALS
return drupal_chmod($htaccess_path, 0444);
}
else {
$variables = array('%directory' => $directory, '@htaccess' => $htaccess_lines);
$variables = ['%directory' => $directory, '@htaccess' => $htaccess_lines];
\Drupal::logger('security')->error("Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines: <pre><code>@htaccess</code></pre>", $variables);
return FALSE;
}
@ -456,7 +456,7 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST
$real_destination = drupal_realpath($destination) ?: $destination;
// Perform the copy operation.
if (!@copy($real_source, $real_destination)) {
\Drupal::logger('file')->error('The specified file %file could not be copied to %destination.', array('%file' => $source, '%destination' => $destination));
\Drupal::logger('file')->error('The specified file %file could not be copied to %destination.', ['%file' => $source, '%destination' => $destination]);
return FALSE;
}
// Set the permissions on the new file.
@ -501,12 +501,12 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
// Assert that the source file actually exists.
if (!file_exists($source)) {
// @todo Replace drupal_set_message() calls with exceptions instead.
drupal_set_message(t('The specified file %file could not be moved/copied because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $original_source)), 'error');
drupal_set_message(t('The specified file %file could not be moved/copied because no file by that name exists. Please check that you supplied the correct filename.', ['%file' => $original_source]), 'error');
if (($realpath = drupal_realpath($original_source)) !== FALSE) {
$logger->notice('File %file (%realpath) could not be moved/copied because it does not exist.', array('%file' => $original_source, '%realpath' => $realpath));
$logger->notice('File %file (%realpath) could not be moved/copied because it does not exist.', ['%file' => $original_source, '%realpath' => $realpath]);
}
else {
$logger->notice('File %file could not be moved/copied because it does not exist.', array('%file' => $original_source));
$logger->notice('File %file could not be moved/copied because it does not exist.', ['%file' => $original_source]);
}
return FALSE;
}
@ -527,8 +527,8 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
$dirname = drupal_dirname($destination);
if (!file_prepare_directory($dirname)) {
// The destination is not valid.
$logger->notice('File %file could not be moved/copied because the destination directory %destination is not configured correctly.', array('%file' => $original_source, '%destination' => $dirname));
drupal_set_message(t('The specified file %file could not be moved/copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', array('%file' => $original_source)), 'error');
$logger->notice('File %file could not be moved/copied because the destination directory %destination is not configured correctly.', ['%file' => $original_source, '%destination' => $dirname]);
drupal_set_message(t('The specified file %file could not be moved/copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', ['%file' => $original_source]), 'error');
return FALSE;
}
}
@ -536,8 +536,8 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
// Determine whether we can perform this operation based on overwrite rules.
$destination = file_destination($destination, $replace);
if ($destination === FALSE) {
drupal_set_message(t('The file %file could not be moved/copied because a file by that name already exists in the destination directory.', array('%file' => $original_source)), 'error');
$logger->notice('File %file could not be moved/copied because a file by that name already exists in the destination directory (%destination)', array('%file' => $original_source, '%destination' => $destination));
drupal_set_message(t('The file %file could not be moved/copied because a file by that name already exists in the destination directory.', ['%file' => $original_source]), 'error');
$logger->notice('File %file could not be moved/copied because a file by that name already exists in the destination directory (%destination)', ['%file' => $original_source, '%destination' => $destination]);
return FALSE;
}
@ -545,8 +545,8 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E
$real_source = drupal_realpath($source);
$real_destination = drupal_realpath($destination);
if ($source == $destination || ($real_source !== FALSE) && ($real_source == $real_destination)) {
drupal_set_message(t('The specified file %file was not moved/copied because it would overwrite itself.', array('%file' => $source)), 'error');
$logger->notice('File %file could not be moved/copied because it would overwrite itself.', array('%file' => $source));
drupal_set_message(t('The specified file %file was not moved/copied because it would overwrite itself.', ['%file' => $source]), 'error');
$logger->notice('File %file could not be moved/copied because it would overwrite itself.', ['%file' => $source]);
return FALSE;
}
// Make sure the .htaccess files are present.
@ -652,7 +652,7 @@ function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXIST
// implemented. It's not necessary to use drupal_unlink() as the Windows
// issue has already been resolved above.
if (!@copy($real_source, $real_destination) || !@unlink($real_source)) {
\Drupal::logger('file')->error('The specified file %file could not be moved to %destination.', array('%file' => $source, '%destination' => $destination));
\Drupal::logger('file')->error('The specified file %file could not be moved to %destination.', ['%file' => $source, '%destination' => $destination]);
return FALSE;
}
}
@ -721,7 +721,7 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) {
$filename = $new_filename . '.' . $final_extension;
if ($alerts && $original != $filename) {
drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $filename)));
drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', ['%filename' => $filename]));
}
}
@ -762,7 +762,7 @@ function file_create_filename($basename, $directory) {
$basename = preg_replace('/[\x00-\x1F]/u', '_', $basename);
if (substr(PHP_OS, 0, 3) == 'WIN') {
// These characters are not allowed in Windows filenames
$basename = str_replace(array(':', '*', '?', '"', '<', '>', '|'), '_', $basename);
$basename = str_replace([':', '*', '?', '"', '<', '>', '|'], '_', $basename);
}
// A URI or path may already have a trailing slash or look like "public://".
@ -810,7 +810,7 @@ function file_create_filename($basename, $directory) {
* @see \Drupal\file\FileUsage\FileUsageBase::delete()
*/
function file_delete($fid) {
return file_delete_multiple(array($fid));
return file_delete_multiple([$fid]);
}
/**
@ -852,18 +852,18 @@ function file_unmanaged_delete($path) {
}
$logger = \Drupal::logger('file');
if (is_dir($path)) {
$logger->error('%path is a directory and cannot be removed using file_unmanaged_delete().', array('%path' => $path));
$logger->error('%path is a directory and cannot be removed using file_unmanaged_delete().', ['%path' => $path]);
return FALSE;
}
// Return TRUE for non-existent file, but log that nothing was actually
// deleted, as the current state is the intended result.
if (!file_exists($path)) {
$logger->notice('The file %path was not deleted because it does not exist.', array('%path' => $path));
$logger->notice('The file %path was not deleted because it does not exist.', ['%path' => $path]);
return TRUE;
}
// We cannot handle anything other than files and directories. Log an error
// for everything else (sockets, symbolic links, etc).
$logger->error('The file %path is not of a recognized type so it was not deleted.', array('%path' => $path));
$logger->error('The file %path is not of a recognized type so it was not deleted.', ['%path' => $path]);
return FALSE;
}
@ -999,14 +999,14 @@ function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EX
* An associative array (keyed on the chosen key) of objects with 'uri',
* 'filename', and 'name' properties corresponding to the matched files.
*/
function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
function file_scan_directory($dir, $mask, $options = [], $depth = 0) {
// Merge in defaults.
$options += array(
$options += [
'callback' => 0,
'recurse' => TRUE,
'key' => 'uri',
'min_depth' => 0,
);
];
// Normalize $dir only once.
if ($depth == 0) {
$dir = file_stream_wrapper_uri_normalize($dir);
@ -1025,8 +1025,8 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
$default_nomask = '/^' . implode('|', $ignore_directories) . '$/';
}
$options['key'] = in_array($options['key'], array('uri', 'filename', 'name')) ? $options['key'] : 'uri';
$files = array();
$options['key'] = in_array($options['key'], ['uri', 'filename', 'name']) ? $options['key'] : 'uri';
$files = [];
// Avoid warnings when opendir does not have the permissions to open a
// directory.
if (is_dir($dir)) {
@ -1067,7 +1067,7 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) {
closedir($handle);
}
else {
\Drupal::logger('file')->error('@dir can not be opened', array('@dir' => $dir));
\Drupal::logger('file')->error('@dir can not be opened', ['@dir' => $dir]);
}
}

View file

@ -29,8 +29,8 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
*/
function template_preprocess_select(&$variables) {
$element = $variables['element'];
Element::setAttributes($element, array('id', 'name', 'size'));
RenderElement::setAttributes($element, array('form-select'));
Element::setAttributes($element, ['id', 'name', 'size']);
RenderElement::setAttributes($element, ['form-select']);
$variables['attributes'] = $element['#attributes'];
$variables['options'] = form_select_options($element);
@ -161,7 +161,7 @@ function form_select_options($element, $choices = NULL) {
* empty if no elements were found. FALSE if optgroups were found.
*/
function form_get_options($element, $key) {
$keys = array();
$keys = [];
foreach ($element['#options'] as $index => $choice) {
if (is_array($choice)) {
return FALSE;
@ -191,9 +191,9 @@ function form_get_options($element, $key) {
*/
function template_preprocess_fieldset(&$variables) {
$element = $variables['element'];
Element::setAttributes($element, array('id'));
Element::setAttributes($element, ['id']);
RenderElement::setAttributes($element);
$variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : array();
$variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : [];
$variables['prefix'] = isset($element['#field_prefix']) ? $element['#field_prefix'] : NULL;
$variables['suffix'] = isset($element['#field_suffix']) ? $element['#field_suffix'] : NULL;
$variables['title_display'] = isset($element['#title_display']) ? $element['#title_display'] : NULL;
@ -207,7 +207,7 @@ function template_preprocess_fieldset(&$variables) {
$variables['legend']['attributes'] = new Attribute();
// Add 'visually-hidden' class to legend span.
if ($variables['title_display'] == 'invisible') {
$variables['legend_span']['attributes'] = new Attribute(array('class' => 'visually-hidden'));
$variables['legend_span']['attributes'] = new Attribute(['class' => ['visually-hidden']]);
}
else {
$variables['legend_span']['attributes'] = new Attribute();
@ -273,7 +273,7 @@ function template_preprocess_details(&$variables) {
*/
function template_preprocess_radios(&$variables) {
$element = $variables['element'];
$variables['attributes'] = array();
$variables['attributes'] = [];
if (isset($element['#id'])) {
$variables['attributes']['id'] = $element['#id'];
}
@ -295,7 +295,7 @@ function template_preprocess_radios(&$variables) {
*/
function template_preprocess_checkboxes(&$variables) {
$element = $variables['element'];
$variables['attributes'] = array();
$variables['attributes'] = [];
if (isset($element['#id'])) {
$variables['attributes']['id'] = $element['#id'];
}
@ -354,7 +354,7 @@ function template_preprocess_form(&$variables) {
if (isset($element['#action'])) {
$element['#attributes']['action'] = UrlHelper::stripDangerousProtocols($element['#action']);
}
Element::setAttributes($element, array('method', 'id'));
Element::setAttributes($element, ['method', 'id']);
if (empty($element['#attributes']['accept-charset'])) {
$element['#attributes']['accept-charset'] = "UTF-8";
}
@ -375,8 +375,8 @@ function template_preprocess_form(&$variables) {
*/
function template_preprocess_textarea(&$variables) {
$element = $variables['element'];
Element::setAttributes($element, array('id', 'name', 'rows', 'cols', 'placeholder'));
RenderElement::setAttributes($element, array('form-textarea'));
Element::setAttributes($element, ['id', 'name', 'rows', 'cols', 'placeholder']);
RenderElement::setAttributes($element, ['form-textarea']);
$variables['wrapper_attributes'] = new Attribute();
$variables['attributes'] = new Attribute($element['#attributes']);
$variables['value'] = $element['#value'];
@ -429,10 +429,11 @@ function template_preprocess_form_element(&$variables) {
// This function is invoked as theme wrapper, but the rendered form element
// may not necessarily have been processed by
// \Drupal::formBuilder()->doBuildForm().
$element += array(
$element += [
'#title_display' => 'before',
'#wrapper_attributes' => array(),
);
'#wrapper_attributes' => [],
'#label_attributes' => [],
];
$variables['attributes'] = $element['#wrapper_attributes'];
// Add element #id for #type 'item'.
@ -477,8 +478,9 @@ function template_preprocess_form_element(&$variables) {
// Add label_display and label variables to template.
$variables['label_display'] = $element['#title_display'];
$variables['label'] = array('#theme' => 'form_element_label');
$variables['label'] += array_intersect_key($element, array_flip(array('#id', '#required', '#title', '#title_display')));
$variables['label'] = ['#theme' => 'form_element_label'];
$variables['label'] += array_intersect_key($element, array_flip(['#id', '#required', '#title', '#title_display']));
$variables['label']['#attributes'] = $element['#label_attributes'];
$variables['children'] = $element['#children'];
}
@ -566,7 +568,7 @@ function template_preprocess_form_element_label(&$variables) {
* Note: if the batch 'title', 'init_message', 'progress_message', or
* 'error_message' could contain any user input, it is the responsibility of
* the code calling batch_set() to sanitize them first with a function like
* \Drupal\Component\Utility\SafeMarkup::checkPlain() or
* \Drupal\Component\Utility\Html::escape() or
* \Drupal\Component\Utility\Xss::filter(). Furthermore, if the batch operation
* returns any user input in the 'results' or 'message' keys of $context, it
* must also sanitize them first.
@ -594,8 +596,8 @@ function template_preprocess_form_element_label(&$variables) {
* $nodes = \Drupal::entityTypeManager()->getStorage('node')
* ->loadByProperties(['uid' => $uid, 'type' => $type]);
* $node = reset($nodes);
* $context['results'][] = $node->id() . ' : ' . SafeMarkup::checkPlain($node->label());
* $context['message'] = SafeMarkup::checkPlain($node->label());
* $context['results'][] = $node->id() . ' : ' . Html::escape($node->label());
* $context['message'] = Html::escape($node->label());
* }
*
* // A more advanced example is a multi-step operation that loads all rows,
@ -614,10 +616,10 @@ function template_preprocess_form_element_label(&$variables) {
* ->range(0, $limit)
* ->execute();
* foreach ($result as $row) {
* $context['results'][] = $row->id . ' : ' . SafeMarkup::checkPlain($row->title);
* $context['results'][] = $row->id . ' : ' . Html::escape($row->title);
* $context['sandbox']['progress']++;
* $context['sandbox']['current_id'] = $row->id;
* $context['message'] = SafeMarkup::checkPlain($row->title);
* $context['message'] = Html::escape($row->title);
* }
* if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
* $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
@ -691,7 +693,7 @@ function template_preprocess_form_element_label(&$variables) {
* 'finished' functions, for instance if they don't reside in the main
* .module file. The path should be relative to base_path(), and thus should
* be built using drupal_get_path().
* - css: Array of paths to CSS files to be used on the progress page.
* - library: An array of batch-specific CSS and JS libraries.
* - url_options: options passed to the \Drupal\Core\Url object when
* constructing redirect URLs for the batch.
* - progressive: A Boolean that indicates whether or not the batch needs to
@ -715,27 +717,26 @@ function batch_set($batch_definition) {
// Initialize the batch if needed.
if (empty($batch)) {
$batch = array(
'sets' => array(),
$batch = [
'sets' => [],
'has_form_submits' => FALSE,
);
];
}
// Base and default properties for the batch set.
$init = array(
'sandbox' => array(),
'results' => array(),
$init = [
'sandbox' => [],
'results' => [],
'success' => FALSE,
'start' => 0,
'elapsed' => 0,
);
$defaults = array(
];
$defaults = [
'title' => t('Processing'),
'init_message' => t('Initializing.'),
'progress_message' => t('Completed @current of @total.'),
'error_message' => t('An error has occurred.'),
'css' => array(),
);
];
$batch_set = $init + $batch_definition + $defaults;
// Tweak init_message to avoid the bottom of the page flickering down after
@ -759,7 +760,7 @@ function batch_set($batch_definition) {
$index = $batch['current_set'] + 1;
$slice1 = array_slice($batch['sets'], 0, $index);
$slice2 = array_slice($batch['sets'], $index);
$batch['sets'] = array_merge($slice1, array($batch_set), $slice2);
$batch['sets'] = array_merge($slice1, [$batch_set], $slice2);
_batch_populate_queue($batch, $index);
}
}
@ -781,6 +782,9 @@ function batch_set($batch_definition) {
* \Symfony\Component\HttpFoundation\RedirectResponse, which will be used
* automatically by the standard batch processing pipeline (and which takes
* precedence over this parameter).
* User will be redirected to the page that started the batch if this argument
* is omitted and no redirect response was returned by the 'finished'
* callback. Any query arguments will be automatically persisted.
* @param \Drupal\Core\Url $url
* (optional - should only be used for separate scripts like update.php)
* URL of the batch processing page.
@ -796,15 +800,15 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N
if (isset($batch)) {
// Add process information
$process_info = array(
$process_info = [
'current_set' => 0,
'progressive' => TRUE,
'url' => isset($url) ? $url : Url::fromRoute('system.batch_page.html'),
'source_url' => Url::fromRouteMatch(\Drupal::routeMatch()),
'source_url' => Url::fromRouteMatch(\Drupal::routeMatch())->mergeOptions(['query' => \Drupal::request()->query->all()]),
'batch_redirect' => $redirect,
'theme' => \Drupal::theme()->getActiveTheme()->getName(),
'redirect_callback' => $redirect_callback,
);
];
$batch += $process_info;
// The batch is now completely built. Allow other modules to make changes
@ -835,7 +839,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N
$query_options['op'] = 'finished';
$error_url->setOption('query', $query_options);
$batch['error_message'] = t('Please continue to <a href=":error_url">the error page</a>', array(':error_url' => $error_url->toString(TRUE)->getGeneratedUrl()));
$batch['error_message'] = t('Please continue to <a href=":error_url">the error page</a>', [':error_url' => $error_url->toString(TRUE)->getGeneratedUrl()]);
// Clear the way for the redirection to the batch processing page, by
// saving and unsetting the 'destination', if there is any.
@ -882,7 +886,7 @@ function &batch_get() {
// that are part of the Batch API and need to reset the batch information may
// call batch_get() and manipulate the result by reference. Functions that are
// not part of the Batch API can also do this, but shouldn't.
static $batch = array();
static $batch = [];
return $batch;
}
@ -903,12 +907,12 @@ function _batch_populate_queue(&$batch, $set_id) {
$batch_set = &$batch['sets'][$set_id];
if (isset($batch_set['operations'])) {
$batch_set += array(
'queue' => array(
$batch_set += [
'queue' => [
'name' => 'drupal_batch:' . $batch['id'] . ':' . $set_id,
'class' => $batch['progressive'] ? 'Drupal\Core\Queue\Batch' : 'Drupal\Core\Queue\BatchMemory',
),
);
],
];
$queue = _batch_queue($batch_set);
$queue->createQueue();
@ -933,7 +937,7 @@ function _batch_queue($batch_set) {
static $queues;
if (!isset($queues)) {
$queues = array();
$queues = [];
}
if (isset($batch_set['queue'])) {

View file

@ -12,6 +12,7 @@ use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\Core\Form\FormState;
use Drupal\Core\Installer\Exception\AlreadyInstalledException;
use Drupal\Core\Installer\Exception\InstallerException;
use Drupal\Core\Installer\Exception\InstallProfileMismatchException;
use Drupal\Core\Installer\Exception\NoProfilesException;
use Drupal\Core\Installer\InstallerKernel;
use Drupal\Core\Language\Language;
@ -91,11 +92,11 @@ const INSTALL_TASK_RUN_IF_NOT_COMPLETED = 3;
*
* @see install_state_defaults()
*/
function install_drupal($class_loader, $settings = array()) {
function install_drupal($class_loader, $settings = []) {
// Support the old way of calling this function with just a settings array.
// @todo Remove this when Drush is updated in the Drupal testing
// infrastructure in https://www.drupal.org/node/2389243
if (is_array($class_loader) && $settings === array()) {
if (is_array($class_loader) && $settings === []) {
$settings = $class_loader;
$class_loader = require __DIR__ . '/../../autoload.php';
}
@ -105,7 +106,7 @@ function install_drupal($class_loader, $settings = array()) {
// as well as a boolean indicating whether or not this is an interactive
// installation.
$interactive = empty($settings);
$install_state = $settings + array('interactive' => $interactive) + install_state_defaults();
$install_state = $settings + ['interactive' => $interactive] + install_state_defaults();
try {
// Begin the page request. This adds information about the current state of
@ -120,10 +121,10 @@ function install_drupal($class_loader, $settings = array()) {
if (!$install_state['interactive']) {
throw $e;
}
$output = array(
$output = [
'#title' => $e->getTitle(),
'#markup' => $e->getMessage(),
);
];
}
// After execution, all tasks might be complete, in which case
@ -181,7 +182,7 @@ function install_drupal($class_loader, $settings = array()) {
* @see \Drupal\Core\Form\FormBuilderInterface::submitForm()
*/
function install_state_defaults() {
$defaults = array(
$defaults = [
// The current task being processed.
'active_task' => NULL,
// The last task that was completed during the previous installation
@ -206,7 +207,7 @@ function install_state_defaults() {
// installation task that the form submission is for, and the values are
// used as the $form_state->getValues() array that is passed on to the form
// submission via \Drupal::formBuilder()->submitForm().
'forms' => array(),
'forms' => [],
// This becomes TRUE only at the end of the installation process, after
// all available tasks have been completed and Drupal is fully installed.
// It is used by the installer to store correct information in the database
@ -223,16 +224,16 @@ function install_state_defaults() {
// and 'langcode' (the code of the chosen installation language), since
// these settings need to persist from page request to page request before
// the database is available for storage.
'parameters' => array(),
'parameters' => [],
// Whether or not the parameters have changed during the current page
// request. For interactive installations, this will trigger a page
// redirect.
'parameters_changed' => FALSE,
// An array of information about the chosen installation profile. This will
// be filled in based on the profile's .info.yml file.
'profile_info' => array(),
'profile_info' => [],
// An array of available installation profiles.
'profiles' => array(),
'profiles' => [],
// The name of the theme to use during installation.
'theme' => 'seven',
// The server URL where the interface translation files can be downloaded.
@ -260,11 +261,11 @@ function install_state_defaults() {
'task_not_complete' => FALSE,
// A list of installation tasks which have already been performed during
// the current page request.
'tasks_performed' => array(),
'tasks_performed' => [],
// An array of translation files URIs available for the installation. Keyed
// by the translation language code.
'translations' => array(),
);
'translations' => [],
];
return $defaults;
}
@ -352,7 +353,7 @@ function install_begin_request($class_loader, &$install_state) {
// Register the stream wrapper manager.
$container
->register('stream_wrapper_manager', 'Drupal\Core\StreamWrapper\StreamWrapperManager')
->addMethodCall('setContainer', array(new Reference('service_container')));
->addMethodCall('setContainer', [new Reference('service_container')]);
$container
->register('file_system', 'Drupal\Core\File\FileSystem')
->addArgument(new Reference('stream_wrapper_manager'))
@ -428,7 +429,7 @@ function install_begin_request($class_loader, &$install_state) {
// Add list of all available profiles to the installation state.
$listing = new ExtensionDiscovery($container->get('app.root'));
$listing->setProfileDirectories(array());
$listing->setProfileDirectories([]);
$install_state['profiles'] += $listing->scan('profile');
// Prime drupal_get_filename()'s static cache.
@ -452,7 +453,7 @@ function install_begin_request($class_loader, &$install_state) {
// Set the default language to the selected language, if any.
if (isset($install_state['parameters']['langcode'])) {
$default_language = new Language(array('id' => $install_state['parameters']['langcode']));
$default_language = new Language(['id' => $install_state['parameters']['langcode']]);
$container->get('language.default')->set($default_language);
\Drupal::translation()->setDefaultLangcode($install_state['parameters']['langcode']);
}
@ -595,7 +596,7 @@ function install_run_task($task, &$install_state) {
}
// Create a one item list of batches if only one batch was provided.
if (isset($batches['operations'])) {
$batches = array($batches);
$batches = [$batches];
}
foreach ($batches as $batch) {
batch_set($batch);
@ -725,26 +726,26 @@ function install_tasks($install_state) {
// Start with the core installation tasks that run before handing control
// to the installation profile.
$tasks = array(
'install_select_language' => array(
$tasks = [
'install_select_language' => [
'display_name' => t('Choose language'),
'run' => INSTALL_TASK_RUN_IF_REACHED,
),
'install_download_translation' => array(
],
'install_download_translation' => [
'run' => $needs_download ? INSTALL_TASK_RUN_IF_REACHED : INSTALL_TASK_SKIP,
),
'install_select_profile' => array(
],
'install_select_profile' => [
'display_name' => t('Choose profile'),
'display' => empty($install_state['profile_info']['distribution']['name']) && count($install_state['profiles']) != 1,
'run' => INSTALL_TASK_RUN_IF_REACHED,
),
'install_load_profile' => array(
],
'install_load_profile' => [
'run' => INSTALL_TASK_RUN_IF_REACHED,
),
'install_verify_requirements' => array(
],
'install_verify_requirements' => [
'display_name' => t('Verify requirements'),
),
'install_settings_form' => array(
],
'install_settings_form' => [
'display_name' => t('Set up database'),
'type' => 'form',
// Even though the form only allows the user to enter database settings,
@ -752,39 +753,39 @@ function install_tasks($install_state) {
// since the form submit handler is where settings.php is rewritten.
'run' => $install_state['settings_verified'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
'function' => 'Drupal\Core\Installer\Form\SiteSettingsForm',
),
'install_write_profile' => array(
),
'install_verify_database_ready' => array(
],
'install_write_profile' => [
],
'install_verify_database_ready' => [
'run' => $install_state['database_ready'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
),
'install_base_system' => array(
],
'install_base_system' => [
'run' => $install_state['base_system_verified'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
),
],
// All tasks below are executed in a regular, full Drupal environment.
'install_bootstrap_full' => array(
'install_bootstrap_full' => [
'run' => INSTALL_TASK_RUN_IF_REACHED,
),
'install_profile_modules' => array(
],
'install_profile_modules' => [
'display_name' => t('Install site'),
'type' => 'batch',
),
'install_profile_themes' => array(
),
'install_install_profile' => array(
),
'install_import_translations' => array(
],
'install_profile_themes' => [
],
'install_install_profile' => [
],
'install_import_translations' => [
'display_name' => t('Set up translations'),
'display' => $needs_translations,
'type' => 'batch',
'run' => $needs_translations ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
),
'install_configure_form' => array(
],
'install_configure_form' => [
'display_name' => t('Configure site'),
'type' => 'form',
'function' => 'Drupal\Core\Installer\Form\SiteConfigureForm',
),
);
],
];
// Now add any tasks defined by the installation profile.
if (!empty($install_state['parameters']['profile'])) {
@ -805,16 +806,16 @@ function install_tasks($install_state) {
}
// Finish by adding the remaining core tasks.
$tasks += array(
'install_finish_translations' => array(
$tasks += [
'install_finish_translations' => [
'display_name' => t('Finish translations'),
'display' => $needs_translations,
'type' => 'batch',
'run' => $needs_translations ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
),
'install_finished' => array(
),
);
],
'install_finished' => [
],
];
// Allow the installation profile to modify the full list of tasks.
if (!empty($install_state['parameters']['profile'])) {
@ -829,13 +830,13 @@ function install_tasks($install_state) {
// Fill in default parameters for each task before returning the list.
foreach ($tasks as $task_name => &$task) {
$task += array(
$task += [
'display_name' => NULL,
'display' => !empty($task['display_name']),
'type' => 'normal',
'run' => INSTALL_TASK_RUN_IF_NOT_COMPLETED,
'function' => $task_name,
);
];
}
return $tasks;
}
@ -856,7 +857,7 @@ function install_tasks($install_state) {
* @see maintenance-task-list.html.twig
*/
function install_tasks_to_display($install_state) {
$displayed_tasks = array();
$displayed_tasks = [];
foreach (install_tasks($install_state) as $name => $task) {
if ($task['display']) {
$displayed_tasks[$name] = $task['display_name'];
@ -970,39 +971,39 @@ function install_display_output($output, $install_state) {
// resulting in /subfolder/install.php being found through search engines.
// When settings.php is writeable this can be used via an external database
// leading a malicious user to gain php access to the server.
$noindex_meta_tag = array(
$noindex_meta_tag = [
'#tag' => 'meta',
'#attributes' => array(
'#attributes' => [
'name' => 'robots',
'content' => 'noindex, nofollow',
),
);
],
];
$output['#attached']['html_head'][] = [$noindex_meta_tag, 'install_meta_robots'];
// Only show the task list if there is an active task; otherwise, the page
// request has ended before tasks have even been started, so there is nothing
// meaningful to show.
$regions = array();
$regions = [];
if (isset($install_state['active_task'])) {
// Let the theming function know when every step of the installation has
// been completed.
$active_task = $install_state['installation_finished'] ? NULL : $install_state['active_task'];
$task_list = array(
$task_list = [
'#theme' => 'maintenance_task_list',
'#items' => install_tasks_to_display($install_state),
'#active' => $active_task,
);
];
$regions['sidebar_first'] = $task_list;
}
$bare_html_page_renderer = \Drupal::service('bare_html_page_renderer');
$response = $bare_html_page_renderer->renderBarePage($output, $output['#title'], 'install_page', $regions);
$default_headers = array(
$default_headers = [
'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT',
'Last-Modified' => gmdate(DATE_RFC1123, REQUEST_TIME),
'Cache-Control' => 'no-cache, must-revalidate',
'ETag' => '"' . REQUEST_TIME . '"',
);
];
$response->headers->add($default_headers);
$response->send();
exit;
@ -1068,13 +1069,13 @@ function install_base_system(&$install_state) {
// Enable the user module so that sessions can be recorded during the
// upcoming bootstrap step.
\Drupal::service('module_installer')->install(array('user'), FALSE);
\Drupal::service('module_installer')->install(['user'], FALSE);
// Save the list of other modules to install for the upcoming tasks.
// State can be set to the database now that system.module is installed.
$modules = $install_state['profile_info']['dependencies'];
\Drupal::state()->set('install_profile_modules', array_diff($modules, array('system')));
\Drupal::state()->set('install_profile_modules', array_diff($modules, ['system']));
$install_state['base_system_verified'] = TRUE;
}
@ -1141,13 +1142,13 @@ function install_verify_database_ready() {
* Checks a database connection and returns any errors.
*/
function install_database_errors($database, $settings_file) {
$errors = array();
$errors = [];
// Check database type.
$database_types = drupal_get_database_types();
$driver = $database['driver'];
if (!isset($database_types[$driver])) {
$errors['driver'] = t("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", array('%settings_file' => $settings_file, '@drupal' => drupal_install_profile_distribution_name(), '%driver' => $driver));
$errors['driver'] = t("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", ['%settings_file' => $settings_file, '@drupal' => drupal_install_profile_distribution_name(), '%driver' => $driver]);
}
else {
// Run driver specific validation
@ -1259,10 +1260,10 @@ function _install_select_profile(&$install_state) {
* @see file_scan_directory()
*/
function install_find_translations() {
$translations = array();
$translations = [];
$files = \Drupal::service('string_translator.file_translation')->findTranslationFiles();
// English does not need a translation file.
array_unshift($files, (object) array('name' => 'en'));
array_unshift($files, (object) ['name' => 'en']);
foreach ($files as $uri => $file) {
// Strip off the file name component before the language code.
$langcode = preg_replace('!^(.+\.)?([^\.]+)$!', '\2', $file->name);
@ -1383,7 +1384,7 @@ function install_retrieve_file($uri, $destination) {
}
try {
$response = \Drupal::httpClient()->get($uri, array('headers' => array('Accept' => 'text/plain')));
$response = \Drupal::httpClient()->get($uri, ['headers' => ['Accept' => 'text/plain']]);
$data = (string) $response->getBody();
if (empty($data)) {
return FALSE;
@ -1490,14 +1491,14 @@ function install_profile_modules(&$install_state) {
// as those will not be handled by the module installer.
install_core_entity_type_definitions();
$modules = \Drupal::state()->get('install_profile_modules') ?: array();
$modules = \Drupal::state()->get('install_profile_modules') ?: [];
$files = system_rebuild_module_data();
\Drupal::state()->delete('install_profile_modules');
// Always install required modules first. Respect the dependencies between
// the modules.
$required = array();
$non_required = array();
$required = [];
$non_required = [];
// Add modules that other modules depend on.
foreach ($modules as $module) {
@ -1517,15 +1518,15 @@ function install_profile_modules(&$install_state) {
arsort($required);
arsort($non_required);
$operations = array();
$operations = [];
foreach ($required + $non_required as $module => $weight) {
$operations[] = array('_install_module_batch', array($module, $files[$module]->info['name']));
$operations[] = ['_install_module_batch', [$module, $files[$module]->info['name']]];
}
$batch = array(
$batch = [
'operations' => $operations,
'title' => t('Installing @drupal', array('@drupal' => drupal_install_profile_distribution_name())),
'title' => t('Installing @drupal', ['@drupal' => drupal_install_profile_distribution_name()]),
'error_message' => t('The installation has encountered an error.'),
);
];
return $batch;
}
@ -1558,7 +1559,7 @@ function install_profile_themes(&$install_state) {
// Ensure that the install profile's theme is used.
// @see _drupal_maintenance_theme()
\Drupal::service('theme.manager')->resetActiveTheme();
\Drupal::theme()->resetActiveTheme();
}
/**
@ -1568,7 +1569,7 @@ function install_profile_themes(&$install_state) {
* An array of information about the current installation state.
*/
function install_install_profile(&$install_state) {
\Drupal::service('module_installer')->install(array(drupal_get_profile()), FALSE);
\Drupal::service('module_installer')->install([drupal_get_profile()], FALSE);
// Install all available optional config. During installation the module order
// is determined by dependencies. If there are no dependencies between modules
// then the order in which they are installed is dependent on random factors
@ -1580,7 +1581,7 @@ function install_install_profile(&$install_state) {
// Ensure that the install profile's theme is used.
// @see _drupal_maintenance_theme()
\Drupal::service('theme.manager')->resetActiveTheme();
\Drupal::theme()->resetActiveTheme();
}
/**
@ -1611,21 +1612,21 @@ function install_download_additional_translations_operations(&$install_state) {
->save();
\Drupal::service('language.default')->set($language);
if (empty($install_state['profile_info']['keep_english'])) {
entity_delete_multiple('configurable_language', array('en'));
entity_delete_multiple('configurable_language', ['en']);
}
}
// If there is more than one language or the single one is not English, we
// should download/import translations.
$languages = \Drupal::languageManager()->getLanguages();
$operations = array();
$operations = [];
foreach ($languages as $langcode => $language) {
// The installer language was already downloaded. Check downloads for the
// other languages if any. Ignore any download errors here, since we
// are in the middle of an install process and there is no way back. We
// will not import what we cannot download.
if ($langcode != 'en' && $langcode != $install_state['parameters']['langcode']) {
$operations[] = array('install_check_translations', array($langcode, $install_state['server_pattern']));
$operations[] = ['install_check_translations', [$langcode, $install_state['server_pattern']]];
}
}
return $operations;
@ -1648,26 +1649,26 @@ function install_import_translations(&$install_state) {
$operations = install_download_additional_translations_operations($install_state);
$languages = \Drupal::languageManager()->getLanguages();
if (count($languages) > 1 || !isset($languages['en'])) {
$operations[] = array('_install_prepare_import', array(array_keys($languages), $install_state['server_pattern']));
$operations[] = ['_install_prepare_import', [array_keys($languages), $install_state['server_pattern']]];
// Set up a batch to import translations for drupal core. Translation import
// for contrib modules happens in install_import_translations_remaining.
foreach ($languages as $language) {
if (locale_translation_use_remote_source()) {
$operations[] = array('locale_translation_batch_fetch_download', array('drupal', $language->getId()));
$operations[] = ['locale_translation_batch_fetch_download', ['drupal', $language->getId()]];
}
$operations[] = array('locale_translation_batch_fetch_import', array('drupal', $language->getId(), array()));
$operations[] = ['locale_translation_batch_fetch_import', ['drupal', $language->getId(), []]];
}
module_load_include('fetch.inc', 'locale');
$batch = array(
$batch = [
'operations' => $operations,
'title' => t('Updating translations.'),
'progress_message' => '',
'error_message' => t('Error importing translation files'),
'finished' => 'locale_translation_batch_fetch_finished',
'file' => drupal_get_path('module', 'locale') . '/locale.batch.inc',
);
];
return $batch;
}
}
@ -1682,11 +1683,11 @@ function install_import_translations(&$install_state) {
*/
function _install_prepare_import($langcodes, $server_pattern) {
\Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc');
$matches = array();
$matches = [];
foreach ($langcodes as $langcode) {
// Get the translation files located in the translations directory.
$files = locale_translate_get_interface_translation_files(array('drupal'), array($langcode));
$files = locale_translate_get_interface_translation_files(['drupal'], [$langcode]);
// Pick the first file which matches the language, if any.
$file = reset($files);
if (is_object($file)) {
@ -1699,17 +1700,17 @@ function _install_prepare_import($langcodes, $server_pattern) {
// we check if at least the major version number is available.
if ($info['major']) {
$core = $info['major'] . '.x';
$data = array(
$data = [
'name' => 'drupal',
'project_type' => 'module',
'core' => $core,
'version' => $version,
'server_pattern' => $server_pattern,
'status' => 1,
);
];
\Drupal::service('locale.project')->set($data['name'], $data);
module_load_include('compare.inc', 'locale');
locale_translation_check_projects_local(array('drupal'), array($langcode));
locale_translation_check_projects_local(['drupal'], [$langcode]);
}
}
}
@ -1738,16 +1739,16 @@ function install_finish_translations(&$install_state) {
// using a batch.
$projects = locale_translation_build_projects();
$languages = \Drupal::languageManager()->getLanguages();
$batches = array();
$batches = [];
if (count($projects) > 1) {
$options = _locale_translation_default_update_options();
if ($batch = locale_translation_batch_update_build(array(), array_keys($languages), $options)) {
if ($batch = locale_translation_batch_update_build([], array_keys($languages), $options)) {
$batches[] = $batch;
}
}
// Creates configuration translations.
$batches[] = locale_config_batch_update_components(array(), array_keys($languages));
$batches[] = locale_config_batch_update_components([], array_keys($languages));
return $batches;
}
@ -1784,9 +1785,9 @@ function install_finished(&$install_state) {
user_login_finalize($account);
}
$success_message = t('Congratulations, you installed @drupal!', array(
$success_message = t('Congratulations, you installed @drupal!', [
'@drupal' => drupal_install_profile_distribution_name(),
));
]);
drupal_set_message($success_message);
}
@ -1796,9 +1797,9 @@ function install_finished(&$install_state) {
* Performs batch installation of modules.
*/
function _install_module_batch($module, $module_name, &$context) {
\Drupal::service('module_installer')->install(array($module), FALSE);
\Drupal::service('module_installer')->install([$module], FALSE);
$context['results'][] = $module;
$context['message'] = t('Installed %module module.', array('%module' => $module_name));
$context['message'] = t('Installed %module module.', ['%module' => $module_name]);
}
/**
@ -1815,7 +1816,7 @@ function _install_module_batch($module, $module_name, &$context) {
* error with detailed information.
*/
function install_check_translations($langcode, $server_pattern) {
$requirements = array();
$requirements = [];
$readable = FALSE;
$writable = FALSE;
@ -1844,12 +1845,12 @@ function install_check_translations($langcode, $server_pattern) {
}
// Build URL for the translation file and the translation server.
$variables = array(
$variables = [
'%project' => 'drupal',
'%version' => \Drupal::VERSION,
'%core' => \Drupal::CORE_COMPATIBILITY,
'%language' => $langcode,
);
];
$translation_url = strtr($server_pattern, $variables);
$elements = parse_url($translation_url);
@ -1873,73 +1874,73 @@ function install_check_translations($langcode, $server_pattern) {
// If the translations directory does not exists, throw an error.
if (!$translations_directory_exists) {
$requirements['translations directory exists'] = array(
$requirements['translations directory exists'] = [
'title' => t('Translations directory'),
'value' => t('The translations directory does not exist.'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The installer requires that you create a translations directory as part of the installation process. Create the directory %translations_directory . More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', array('%translations_directory' => $translations_directory, ':install_txt' => base_path() . 'core/INSTALL.txt')),
);
'description' => t('The installer requires that you create a translations directory as part of the installation process. Create the directory %translations_directory . More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', ['%translations_directory' => $translations_directory, ':install_txt' => base_path() . 'core/INSTALL.txt']),
];
}
else {
$requirements['translations directory exists'] = array(
$requirements['translations directory exists'] = [
'title' => t('Translations directory'),
'value' => t('The directory %translations_directory exists.', array('%translations_directory' => $translations_directory)),
);
'value' => t('The directory %translations_directory exists.', ['%translations_directory' => $translations_directory]),
];
// If the translations directory is not readable, throw an error.
if (!$readable) {
$requirements['translations directory readable'] = array(
$requirements['translations directory readable'] = [
'title' => t('Translations directory'),
'value' => t('The translations directory is not readable.'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The installer requires read permissions to %translations_directory at all times. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', array('%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions')),
);
'description' => t('The installer requires read permissions to %translations_directory at all times. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', ['%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']),
];
}
// If translations directory is not writable, throw an error.
if (!$writable) {
$requirements['translations directory writable'] = array(
$requirements['translations directory writable'] = [
'title' => t('Translations directory'),
'value' => t('The translations directory is not writable.'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The installer requires write permissions to %translations_directory during the installation process. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', array('%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions')),
);
'description' => t('The installer requires write permissions to %translations_directory during the installation process. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', ['%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']),
];
}
else {
$requirements['translations directory writable'] = array(
$requirements['translations directory writable'] = [
'title' => t('Translations directory'),
'value' => t('The translations directory is writable.'),
);
];
}
}
// If the translations server can not be contacted, throw an error.
if (!$online) {
$requirements['online'] = array(
$requirements['online'] = [
'title' => t('Internet'),
'value' => t('The translation server is offline.'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The installer requires to contact the translation server to download a translation file. Check your internet connection and verify that your website can reach the translation server at <a href=":server_url">@server_url</a>.', array(':server_url' => $server_url, '@server_url' => $server_url)),
);
'description' => t('The installer requires to contact the translation server to download a translation file. Check your internet connection and verify that your website can reach the translation server at <a href=":server_url">@server_url</a>.', [':server_url' => $server_url, '@server_url' => $server_url]),
];
}
else {
$requirements['online'] = array(
$requirements['online'] = [
'title' => t('Internet'),
'value' => t('The translation server is online.'),
);
];
// If translation file is not found at the translation server, throw an
// error.
if (!$translation_available) {
$requirements['translation available'] = array(
$requirements['translation available'] = [
'title' => t('Translation'),
'value' => t('The %language translation is not available.', array('%language' => $language)),
'value' => t('The %language translation is not available.', ['%language' => $language]),
'severity' => REQUIREMENT_ERROR,
'description' => t('The %language translation file is not available at the translation server. <a href=":url">Choose a different language</a> or select English and translate your website later.', array('%language' => $language, ':url' => $_SERVER['SCRIPT_NAME'])),
);
'description' => t('The %language translation file is not available at the translation server. <a href=":url">Choose a different language</a> or select English and translate your website later.', ['%language' => $language, ':url' => $_SERVER['SCRIPT_NAME']]),
];
}
else {
$requirements['translation available'] = array(
$requirements['translation available'] = [
'title' => t('Translation'),
'value' => t('The %language translation is available.', array('%language' => $language)),
);
'value' => t('The %language translation is available.', ['%language' => $language]),
];
}
}
@ -1947,12 +1948,12 @@ function install_check_translations($langcode, $server_pattern) {
$translation_downloaded = install_retrieve_file($translation_url, $translations_directory);
if (!$translation_downloaded) {
$requirements['translation downloaded'] = array(
$requirements['translation downloaded'] = [
'title' => t('Translation'),
'value' => t('The %language translation could not be downloaded.', array('%language' => $language)),
'value' => t('The %language translation could not be downloaded.', ['%language' => $language]),
'severity' => REQUIREMENT_ERROR,
'description' => t('The %language translation file could not be downloaded. <a href=":url">Choose a different language</a> or select English and translate your website later.', array('%language' => $language, ':url' => $_SERVER['SCRIPT_NAME'])),
);
'description' => t('The %language translation file could not be downloaded. <a href=":url">Choose a different language</a> or select English and translate your website later.', ['%language' => $language, ':url' => $_SERVER['SCRIPT_NAME']]),
];
}
}
@ -1974,14 +1975,14 @@ function install_check_requirements($install_state) {
// If Drupal is not set up already, we need to try to create the default
// settings and services files.
$default_files = array();
$default_files['settings.php'] = array(
$default_files = [];
$default_files['settings.php'] = [
'file' => 'settings.php',
'file_default' => 'default.settings.php',
'title_default' => t('Default settings file'),
'description_default' => t('The default settings file does not exist.'),
'title' => t('Settings file'),
);
];
foreach ($default_files as $default_file_info) {
$readable = FALSE;
@ -2003,15 +2004,15 @@ function install_check_requirements($install_state) {
// If the default $default_file does not exist, or is not readable,
// report an error.
if (!drupal_verify_install_file($default_file, FILE_EXIST | FILE_READABLE)) {
$requirements["default $file file exists"] = array(
$requirements["default $file file exists"] = [
'title' => $default_file_info['title_default'],
'value' => $default_file_info['description_default'],
'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(
'description' => t('The @drupal installer requires that the %default-file file not be modified in any way from the original download.', [
'@drupal' => drupal_install_profile_distribution_name(),
'%default-file' => $default_file
)),
);
]),
];
}
// Otherwise, if $file does not exist yet, we can try to copy
// $default_file to create it.
@ -2062,68 +2063,68 @@ function install_check_requirements($install_state) {
// If the $file does not exist, throw an error.
if (!$exists) {
$requirements["$file file exists"] = array(
$requirements["$file file exists"] = [
'title' => $default_file_info['title'],
'value' => t('The %file does not exist.', array('%file' => $default_file_info['title'])),
'value' => t('The %file does not exist.', ['%file' => $default_file_info['title']]),
'severity' => REQUIREMENT_ERROR,
'description' => t('The @drupal installer requires that you create a %file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', array(
'description' => t('The @drupal installer requires that you create a %file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', [
'@drupal' => drupal_install_profile_distribution_name(),
'%file' => $file,
'%default_file' => $default_file,
':install_txt' => base_path() . 'core/INSTALL.txt'
)),
);
]),
];
}
else {
$requirements["$file file exists"] = array(
$requirements["$file file exists"] = [
'title' => $default_file_info['title'],
'value' => t('The %file exists.', array('%file' => $file)),
);
'value' => t('The %file exists.', ['%file' => $file]),
];
// If the $file is not readable, throw an error.
if (!$readable) {
$requirements["$file file readable"] = array(
$requirements["$file file readable"] = [
'title' => $default_file_info['title'],
'value' => t('The %file is not readable.', array('%file' => $default_file_info['title'])),
'value' => t('The %file is not readable.', ['%file' => $default_file_info['title']]),
'severity' => REQUIREMENT_ERROR,
'description' => t('@drupal requires read permissions to %file at all times. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', array(
'description' => t('@drupal requires read permissions to %file at all times. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', [
'@drupal' => drupal_install_profile_distribution_name(),
'%file' => $file,
':handbook_url' => 'https://www.drupal.org/server-permissions'
)),
);
]),
];
}
// If the $file is not writable, throw an error.
if (!$writable) {
$requirements["$file file writeable"] = array(
$requirements["$file file writeable"] = [
'title' => $default_file_info['title'],
'value' => t('The %file is not writable.', array('%file' => $default_file_info['title'])),
'value' => t('The %file is not writable.', ['%file' => $default_file_info['title']]),
'severity' => REQUIREMENT_ERROR,
'description' => t('The @drupal installer requires write permissions to %file during the installation process. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', array(
'description' => t('The @drupal installer requires write permissions to %file during the installation process. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', [
'@drupal' => drupal_install_profile_distribution_name(),
'%file' => $file,
':handbook_url' => 'https://www.drupal.org/server-permissions'
)),
);
]),
];
}
else {
$requirements["$file file"] = array(
$requirements["$file file"] = [
'title' => $default_file_info['title'],
'value' => t('The @file is writable.', array('@file' => $default_file_info['title'])),
);
'value' => t('The @file is writable.', ['@file' => $default_file_info['title']]),
];
}
if (!empty($settings_file_ownership_error)) {
$requirements["$file file ownership"] = array(
$requirements["$file file ownership"] = [
'title' => $default_file_info['title'],
'value' => t('The @file is owned by the web server.', array('@file' => $default_file_info['title'])),
'value' => t('The @file is owned by the web server.', ['@file' => $default_file_info['title']]),
'severity' => REQUIREMENT_ERROR,
'description' => t('The @drupal installer failed to create a %file file with proper file ownership. Log on to your web server, remove the existing %file file, and create a new one by copying the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', array(
'description' => t('The @drupal installer failed to create a %file file with proper file ownership. Log on to your web server, remove the existing %file file, and create a new one by copying the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', [
'@drupal' => drupal_install_profile_distribution_name(),
'%file' => $file,
'%default_file' => $default_file,
':install_txt' => base_path() . 'core/INSTALL.txt',
':handbook_url' => 'https://www.drupal.org/server-permissions'
)),
);
]),
];
}
}
}
@ -2157,21 +2158,21 @@ function install_display_requirements($install_state, $requirements) {
// and indicating a desire to continue anyway. See drupal_requirements_url().
if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && empty($install_state['parameters']['continue']))) {
if ($install_state['interactive']) {
$build['report']['#theme'] = 'status_report';
$build['report']['#type'] = 'status_report';
$build['report']['#requirements'] = $requirements;
if ($severity == REQUIREMENT_WARNING) {
$build['#title'] = t('Requirements review');
$build['#suffix'] = t('Check the messages and <a href=":retry">retry</a>, or you may choose to <a href=":cont">continue anyway</a>.', array(':retry' => drupal_requirements_url(REQUIREMENT_ERROR), ':cont' => drupal_requirements_url($severity)));
$build['#suffix'] = t('Check the messages and <a href=":retry">retry</a>, or you may choose to <a href=":cont">continue anyway</a>.', [':retry' => drupal_requirements_url(REQUIREMENT_ERROR), ':cont' => drupal_requirements_url($severity)]);
}
else {
$build['#title'] = t('Requirements problem');
$build['#suffix'] = t('Check the messages and <a href=":url">try again</a>.', array(':url' => drupal_requirements_url($severity)));
$build['#suffix'] = t('Check the messages and <a href=":url">try again</a>.', [':url' => drupal_requirements_url($severity)]);
}
return $build;
}
else {
// Throw an exception showing any unmet requirements.
$failures = array();
$failures = [];
foreach ($requirements as $requirement) {
// Skip warnings altogether for non-interactive installations; these
// proceed in a single request so there is no good opportunity (and no
@ -2188,18 +2189,31 @@ function install_display_requirements($install_state, $requirements) {
}
/**
* Installation task; ensures install profile is written to settings.php.
* Installation task; writes profile to settings.php if possible.
*
* @param array $install_state
* An array of information about the current installation state.
*
* @see _install_select_profile()
*
* @throws \Drupal\Core\Installer\Exception\InstallProfileMismatchException
*
* @deprecated in Drupal 8.3.0 and will be removed before Drupal 9.0.0. The
* install profile is written to core.extension.
*/
function install_write_profile($install_state) {
if (Settings::get('install_profile') !== $install_state['parameters']['profile']) {
// Only need to write to settings.php if it is possible. The primary storage
// for the install profile is the core.extension configuration.
$settings_path = \Drupal::service('site.path') . '/settings.php';
if (is_writable($settings_path)) {
// Remember the profile which was used.
$settings['settings']['install_profile'] = (object) array(
$settings['settings']['install_profile'] = (object) [
'value' => $install_state['parameters']['profile'],
'required' => TRUE,
);
];
drupal_rewrite_settings($settings);
}
elseif (($settings_profile = Settings::get('install_profile')) && $settings_profile !== $install_state['parameters']['profile']) {
throw new InstallProfileMismatchException($install_state['parameters']['profile'], $settings_profile, $settings_path, \Drupal::translation());
}
}

View file

@ -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;
}
@ -621,8 +621,14 @@ function drupal_install_system($install_state) {
// Install base system configuration.
\Drupal::service('config.installer')->installDefaultConfig('core', 'core');
// Store the installation profile in configuration to populate the
// 'install_profile' container parameter.
\Drupal::configFactory()->getEditable('core.extension')
->set('profile', $install_state['parameters']['profile'])
->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.
@ -663,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) {
@ -729,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) {
@ -783,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
@ -845,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();
}
@ -880,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)) {
@ -910,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) {
@ -931,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
@ -994,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');
}
@ -1060,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));

View file

@ -28,27 +28,27 @@ use Drupal\Core\Render\Element;
*/
function template_preprocess_menu_local_task(&$variables) {
$link = $variables['element']['#link'];
$link += array(
'localized_options' => array(),
);
$link += [
'localized_options' => [],
];
$link_text = $link['title'];
if (!empty($variables['element']['#active'])) {
$variables['is_active'] = TRUE;
// Add text to indicate active tab for non-visual users.
$active = SafeMarkup::format('<span class="visually-hidden">@label</span>', array('@label' => t('(active tab)')));
$link_text = t('@local-task-title@active', array('@local-task-title' => $link_text, '@active' => $active));
$active = SafeMarkup::format('<span class="visually-hidden">@label</span>', ['@label' => t('(active tab)')]);
$link_text = t('@local-task-title@active', ['@local-task-title' => $link_text, '@active' => $active]);
}
$link['localized_options']['set_active_class'] = TRUE;
$variables['link'] = array(
$variables['link'] = [
'#type' => 'link',
'#title' => $link_text,
'#url' => $link['url'],
'#options' => $link['localized_options'],
);
];
}
/**
@ -64,32 +64,32 @@ function template_preprocess_menu_local_task(&$variables) {
*/
function template_preprocess_menu_local_action(&$variables) {
$link = $variables['element']['#link'];
$link += array(
'localized_options' => array(),
);
$link += [
'localized_options' => [],
];
$link['localized_options']['attributes']['class'][] = 'button';
$link['localized_options']['attributes']['class'][] = 'button-action';
$link['localized_options']['set_active_class'] = TRUE;
$variables['link'] = array(
$variables['link'] = [
'#type' => 'link',
'#title' => $link['title'],
'#options' => $link['localized_options'],
'#url' => $link['url'],
);
];
}
/**
* Returns an array containing the names of system-defined (default) menus.
*/
function menu_list_system_menus() {
return array(
return [
'tools' => 'Tools',
'admin' => 'Administration',
'account' => 'User account menu',
'main' => 'Main navigation',
'footer' => 'Footer menu',
);
];
}
/**
@ -144,12 +144,12 @@ function menu_secondary_local_tasks() {
* Returns a renderable element for the primary and secondary tabs.
*/
function menu_local_tabs() {
$build = array(
$build = [
'#theme' => 'menu_local_tasks',
'#primary' => menu_primary_local_tasks(),
'#secondary' => menu_secondary_local_tasks(),
);
return !empty($build['#primary']) || !empty($build['#secondary']) ? $build : array();
];
return !empty($build['#primary']) || !empty($build['#secondary']) ? $build : [];
}
/**

View file

@ -27,19 +27,19 @@ function system_list($type) {
$lists = $cached->data;
}
else {
$lists = array(
'theme' => array(),
'filepaths' => array(),
);
$lists = [
'theme' => [],
'filepaths' => [],
];
// ThemeHandler maintains the 'system.theme.data' state record.
$theme_data = \Drupal::state()->get('system.theme.data', array());
$theme_data = \Drupal::state()->get('system.theme.data', []);
foreach ($theme_data as $name => $theme) {
$lists['theme'][$name] = $theme;
$lists['filepaths'][] = array(
$lists['filepaths'][] = [
'type' => 'theme',
'name' => $name,
'filepath' => $theme->getPathname(),
);
];
}
\Drupal::cache('bootstrap')->set('system_list', $lists);
}
@ -146,7 +146,7 @@ function module_load_include($type, $module, $name = NULL) {
function drupal_required_modules() {
$listing = new ExtensionDiscovery(\Drupal::root());
$files = $listing->scan('module');
$required = array();
$required = [];
// Unless called by the installer, an installation profile is required and
// must always be loaded. drupal_get_profile() also returns the installation
@ -191,7 +191,7 @@ function module_set_weight($module, $weight) {
$current_module_filenames = $module_handler->getModuleList();
$current_modules = array_fill_keys(array_keys($current_module_filenames), 0);
$current_modules = module_config_sort(array_merge($current_modules, $extension_config->get('module')));
$module_filenames = array();
$module_filenames = [];
foreach ($current_modules as $name => $weight) {
$module_filenames[$name] = $current_module_filenames[$name];
}
@ -222,7 +222,7 @@ function module_config_sort($data) {
// two modules and weights (spaces added for clarity):
// - Block with weight -5: 0 0000000000000000005 block
// - Node with weight 0: 1 0000000000000000000 node
$sort = array();
$sort = [];
foreach ($data as $name => $weight) {
// Prefix negative weights with 0, positive weights with 1.
// +/- signs cannot be used, since + (ASCII 43) is before - (ASCII 45).

View file

@ -147,7 +147,7 @@ function pager_default_initialize($total, $limit, $element = 0) {
function pager_get_query_parameters() {
$query = &drupal_static(__FUNCTION__);
if (!isset($query)) {
$query = UrlHelper::filterQueryParameters(\Drupal::request()->query->all(), array('page'));
$query = UrlHelper::filterQueryParameters(\Drupal::request()->query->all(), ['page']);
}
return $query;
}
@ -216,19 +216,19 @@ function template_preprocess_pager(&$variables) {
// Create the "first" and "previous" links if we are not on the first page.
if ($pager_page_array[$element] > 0) {
$items['first'] = array();
$options = array(
$items['first'] = [];
$options = [
'query' => pager_query_add_page($parameters, $element, 0),
);
];
$items['first']['href'] = \Drupal::url($route_name, $route_parameters, $options);
if (isset($tags[0])) {
$items['first']['text'] = $tags[0];
}
$items['previous'] = array();
$options = array(
$items['previous'] = [];
$options = [
'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1),
);
];
$items['previous']['href'] = \Drupal::url($route_name, $route_parameters, $options);
if (isset($tags[1])) {
$items['previous']['text'] = $tags[1];
@ -242,9 +242,9 @@ function template_preprocess_pager(&$variables) {
}
// Now generate the actual pager piece.
for (; $i <= $pager_last && $i <= $pager_max; $i++) {
$options = array(
$options = [
'query' => pager_query_add_page($parameters, $element, $i - 1),
);
];
$items['pages'][$i]['href'] = \Drupal::url($route_name, $route_parameters, $options);
if ($i == $pager_current) {
$variables['current'] = $i;
@ -258,19 +258,19 @@ function template_preprocess_pager(&$variables) {
// Create the "next" and "last" links if we are not on the last page.
if ($pager_page_array[$element] < ($pager_max - 1)) {
$items['next'] = array();
$options = array(
$items['next'] = [];
$options = [
'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1),
);
];
$items['next']['href'] = \Drupal::url($route_name, $route_parameters, $options);
if (isset($tags[3])) {
$items['next']['text'] = $tags[3];
}
$items['last'] = array();
$options = array(
$items['last'] = [];
$options = [
'query' => pager_query_add_page($parameters, $element, $pager_max - 1),
);
];
$items['last']['href'] = \Drupal::url($route_name, $route_parameters, $options);
if (isset($tags[4])) {
$items['last']['text'] = $tags[4];

View file

@ -28,9 +28,9 @@ const SCHEMA_UNINSTALLED = -1;
function drupal_get_schema_versions($module) {
$updates = &drupal_static(__FUNCTION__, NULL);
if (!isset($updates[$module])) {
$updates = array();
$updates = [];
foreach (\Drupal::moduleHandler()->getModuleList() as $loaded_module => $filename) {
$updates[$loaded_module] = array();
$updates[$loaded_module] = [];
}
// Prepare regular expression to match all possible defined hook_update_N().
@ -74,15 +74,15 @@ function drupal_get_schema_versions($module) {
* module is not installed.
*/
function drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE) {
$versions = &drupal_static(__FUNCTION__, array());
$versions = &drupal_static(__FUNCTION__, []);
if ($reset) {
$versions = array();
$versions = [];
}
if (!$versions) {
if (!$versions = \Drupal::keyValue('system.schema')->getAll()) {
$versions = array();
$versions = [];
}
}
@ -162,12 +162,12 @@ function drupal_get_module_schema($module, $table = NULL) {
if (isset($schema[$table])) {
return $schema[$table];
}
return array();
return [];
}
elseif (!empty($schema)) {
return $schema;
}
return array();
return [];
}
/**

View file

@ -41,7 +41,7 @@ function tablesort_init($header) {
function tablesort_header(&$cell_content, array &$cell_attributes, array $header, array $ts) {
// Special formatting for the currently sorted column header.
if (isset($cell_attributes['field'])) {
$title = t('sort by @s', array('@s' => $cell_content));
$title = t('sort by @s', ['@s' => $cell_content]);
if ($cell_content == $ts['name']) {
// aria-sort is a WAI-ARIA property that indicates if items in a table
// or grid are sorted in ascending or descending order. See
@ -49,10 +49,10 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header
$cell_attributes['aria-sort'] = ($ts['sort'] == 'asc') ? 'ascending' : 'descending';
$ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc');
$cell_attributes['class'][] = 'is-active';
$tablesort_indicator = array(
$tablesort_indicator = [
'#theme' => 'tablesort_indicator',
'#style' => $ts['sort'],
);
];
$image = drupal_render($tablesort_indicator);
}
else {
@ -60,12 +60,12 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header
$ts['sort'] = 'asc';
$image = '';
}
$cell_content = \Drupal::l(SafeMarkup::format('@cell_content@image', array('@cell_content' => $cell_content, '@image' => $image)), new Url('<current>', [], [
'attributes' => array('title' => $title),
'query' => array_merge($ts['query'], array(
$cell_content = \Drupal::l(SafeMarkup::format('@cell_content@image', ['@cell_content' => $cell_content, '@image' => $image]), new Url('<current>', [], [
'attributes' => ['title' => $title],
'query' => array_merge($ts['query'], [
'sort' => $ts['sort'],
'order' => $cell_content,
)),
]),
]));
unset($cell_attributes['field'], $cell_attributes['sort']);
@ -80,7 +80,7 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header
* page request except for those pertaining to table sorting.
*/
function tablesort_get_query_parameters() {
return UrlHelper::filterQueryParameters(\Drupal::request()->query->all(), array('sort', 'order'));
return UrlHelper::filterQueryParameters(\Drupal::request()->query->all(), ['sort', 'order']);
}
/**
@ -112,12 +112,12 @@ function tablesort_get_order($headers) {
if (!isset($default)) {
$default = reset($headers);
if (!is_array($default)) {
$default = array('data' => $default);
$default = ['data' => $default];
}
}
$default += array('data' => NULL, 'field' => NULL);
return array('name' => $default['data'], 'sql' => $default['field']);
$default += ['data' => NULL, 'field' => NULL];
return ['name' => $default['data'], 'sql' => $default['field']];
}
/**

View file

@ -102,13 +102,13 @@ function theme_get_registry($complete = TRUE) {
* @see \Drupal\Core\Extension\ThemeHandler::$defaultFeatures
*/
function _system_default_theme_features() {
return array(
return [
'favicon',
'logo',
'node_user_picture',
'comment_user_picture',
'comment_user_verification',
);
];
}
/**
@ -134,7 +134,7 @@ function drupal_theme_rebuild() {
*/
function drupal_find_theme_functions($cache, $prefixes) {
$implementations = [];
$grouped_functions = \Drupal::service('theme.registry')->getPrefixGroupedUserFunctions();
$grouped_functions = \Drupal::service('theme.registry')->getPrefixGroupedUserFunctions($prefixes);
foreach ($cache as $hook => $info) {
foreach ($prefixes as $prefix) {
@ -158,11 +158,11 @@ function drupal_find_theme_functions($cache, $prefixes) {
foreach ($matches as $match) {
$new_hook = substr($match, strlen($prefix) + 1);
$arg_name = isset($info['variables']) ? 'variables' : 'render element';
$implementations[$new_hook] = array(
$implementations[$new_hook] = [
'function' => $match,
$arg_name => $info[$arg_name],
'base hook' => $hook,
);
];
}
}
}
@ -170,9 +170,9 @@ function drupal_find_theme_functions($cache, $prefixes) {
// that in what is returned so that the registry knows that the theme has
// this implementation.
if (function_exists($prefix . '_' . $hook)) {
$implementations[$hook] = array(
$implementations[$hook] = [
'function' => $prefix . '_' . $hook,
);
];
}
}
}
@ -191,12 +191,12 @@ function drupal_find_theme_functions($cache, $prefixes) {
* The path to search.
*/
function drupal_find_theme_templates($cache, $extension, $path) {
$implementations = array();
$implementations = [];
// Collect paths to all sub-themes grouped by base themes. These will be
// used for filtering. This allows base themes to have sub-themes in its
// folder hierarchy without affecting the base themes template discovery.
$theme_paths = array();
$theme_paths = [];
foreach (\Drupal::service('theme_handler')->listInfo() as $theme_info) {
if (!empty($theme_info->base_theme)) {
$theme_paths[$theme_info->base_theme][$theme_info->getName()] = $theme_info->getPath();
@ -210,12 +210,12 @@ function drupal_find_theme_templates($cache, $extension, $path) {
}
}
$theme = \Drupal::theme()->getActiveTheme()->getName();
$subtheme_paths = isset($theme_paths[$theme]) ? $theme_paths[$theme] : array();
$subtheme_paths = isset($theme_paths[$theme]) ? $theme_paths[$theme] : [];
// Escape the periods in the extension.
$regex = '/' . str_replace('.', '\.', $extension) . '$/';
// Get a listing of all template files in the path to search.
$files = file_scan_directory($path, $regex, array('key' => 'filename'));
$files = file_scan_directory($path, $regex, ['key' => 'filename']);
// Find templates that implement registered theme hooks and include that in
// what is returned so that the registry knows that the theme has this
@ -231,21 +231,21 @@ function drupal_find_theme_templates($cache, $extension, $path) {
// for the purposes of searching.
$hook = strtr($template, '-', '_');
if (isset($cache[$hook])) {
$implementations[$hook] = array(
$implementations[$hook] = [
'template' => $template,
'path' => dirname($file->uri),
);
];
}
// Match templates based on the 'template' filename.
foreach ($cache as $hook => $info) {
if (isset($info['template'])) {
$template_candidates = array($info['template'], str_replace($info['theme path'] . '/templates/', '', $info['template']));
$template_candidates = [$info['template'], str_replace($info['theme path'] . '/templates/', '', $info['template'])];
if (in_array($template, $template_candidates)) {
$implementations[$hook] = array(
$implementations[$hook] = [
'template' => $template,
'path' => dirname($file->uri),
);
];
}
}
}
@ -272,12 +272,12 @@ function drupal_find_theme_templates($cache, $extension, $path) {
// Put the underscores back in for the hook name and register this
// pattern.
$arg_name = isset($info['variables']) ? 'variables' : 'render element';
$implementations[strtr($file, '-', '_')] = array(
$implementations[strtr($file, '-', '_')] = [
'template' => $file,
'path' => dirname($files[$match]->uri),
$arg_name => $info[$arg_name],
'base hook' => $hook,
);
];
}
}
}
@ -305,7 +305,7 @@ function drupal_find_theme_templates($cache, $extension, $path) {
*/
function theme_get_setting($setting_name, $theme = NULL) {
/** @var \Drupal\Core\Theme\ThemeSettings[] $cache */
$cache = &drupal_static(__FUNCTION__, array());
$cache = &drupal_static(__FUNCTION__, []);
// If no key is given, use the current theme if we can determine it.
if (!isset($theme)) {
@ -488,7 +488,7 @@ function theme_settings_convert_to_config(array $theme_settings, Config $config)
elseif (substr($key, 0, 7) == 'toggle_') {
$config->set('features.' . Unicode::substr($key, 7), $value);
}
elseif (!in_array($key, array('theme', 'logo_upload'))) {
elseif (!in_array($key, ['theme', 'logo_upload'])) {
$config->set($key, $value);
}
}
@ -545,7 +545,7 @@ function template_preprocess_time(&$variables) {
function template_preprocess_datetime_form(&$variables) {
$element = $variables['element'];
$variables['attributes'] = array();
$variables['attributes'] = [];
if (isset($element['#id'])) {
$variables['attributes']['id'] = $element['#id'];
}
@ -576,8 +576,14 @@ function template_preprocess_datetime_wrapper(&$variables) {
// Suppress error messages.
$variables['errors'] = NULL;
$variables['description'] = NULL;
if (!empty($element['#description'])) {
$description_attributes = [];
if (!empty($element['#id'])) {
$description_attributes['id'] = $element['#id'] . '--description';
}
$variables['description'] = $element['#description'];
$variables['description_attributes'] = new Attribute($description_attributes);
}
$variables['required'] = FALSE;
@ -658,34 +664,34 @@ function template_preprocess_links(&$variables) {
if (!empty($heading)) {
// Convert a string heading into an array, using a <h2> tag by default.
if (is_string($heading)) {
$heading = array('text' => $heading);
$heading = ['text' => $heading];
}
// Merge in default array properties into $heading.
$heading += array(
$heading += [
'level' => 'h2',
'attributes' => array(),
);
'attributes' => [],
];
// Convert the attributes array into an Attribute object.
$heading['attributes'] = new Attribute($heading['attributes']);
}
$variables['links'] = array();
$variables['links'] = [];
foreach ($links as $key => $link) {
$item = array();
$link += array(
$item = [];
$link += [
'ajax' => NULL,
'url' => NULL,
);
];
$li_attributes = array();
$li_attributes = [];
$keys = ['title', 'url'];
$link_element = array(
$link_element = [
'#type' => 'link',
'#title' => $link['title'],
'#options' => array_diff_key($link, array_combine($keys, $keys)),
'#url' => $link['url'],
'#ajax' => $link['ajax'],
);
];
// Handle links and ensure that the active class is added on the LIs, but
// only if the 'set_active_class' option is not empty.
@ -773,7 +779,7 @@ function template_preprocess_image(&$variables) {
// Generate a srcset attribute conforming to the spec at
// http://www.w3.org/html/wg/drafts/html/master/embedded-content.html#attr-img-srcset
if (!empty($variables['srcset'])) {
$srcset = array();
$srcset = [];
foreach ($variables['srcset'] as $src) {
// URI is mandatory.
$source = file_url_transform_relative(file_create_url($src['uri']));
@ -788,7 +794,7 @@ function template_preprocess_image(&$variables) {
$variables['attributes']['srcset'] = implode(', ', $srcset);
}
foreach (array('width', 'height', 'alt', 'title', 'sizes') as $key) {
foreach (['width', 'height', 'alt', 'title', 'sizes'] as $key) {
if (isset($variables[$key])) {
// If the property has already been defined in the attributes,
// do not override, including NULL.
@ -902,11 +908,11 @@ function template_preprocess_table(&$variables) {
}
else {
$cols = $colgroup;
$colgroup_attributes = array();
$colgroup_attributes = [];
}
$colgroup = array();
$colgroup = [];
$colgroup['attributes'] = new Attribute($colgroup_attributes);
$colgroup['cols'] = array();
$colgroup['cols'] = [];
// Build columns.
if (is_array($cols) && !empty($cols)) {
@ -918,10 +924,10 @@ function template_preprocess_table(&$variables) {
}
// Build an associative array of responsive classes keyed by column.
$responsive_classes = array();
$responsive_classes = [];
// Format the table header:
$ts = array();
$ts = [];
$header_columns = 0;
if (!empty($variables['header'])) {
$ts = tablesort_init($variables['header']);
@ -973,7 +979,7 @@ function template_preprocess_table(&$variables) {
// tablesort_header() removes the 'sort' and 'field' keys.
$cell_attributes = new Attribute($cell);
}
$variables['header'][$col_key] = array();
$variables['header'][$col_key] = [];
$variables['header'][$col_key]['tag'] = $is_header ? 'th' : 'td';
$variables['header'][$col_key]['attributes'] = $cell_attributes;
$variables['header'][$col_key]['content'] = $cell_content;
@ -982,12 +988,12 @@ function template_preprocess_table(&$variables) {
$variables['header_columns'] = $header_columns;
// Rows and footer have the same structure.
$sections = array('rows' , 'footer');
$sections = ['rows' , 'footer'];
foreach ($sections as $section) {
if (!empty($variables[$section])) {
foreach ($variables[$section] as $row_key => $row) {
$cells = $row;
$row_attributes = array();
$row_attributes = [];
// Check if we're dealing with a simple or complex row
if (isset($row['data'])) {
@ -1001,9 +1007,9 @@ function template_preprocess_table(&$variables) {
}
// Build row.
$variables[$section][$row_key] = array();
$variables[$section][$row_key] = [];
$variables[$section][$row_key]['attributes'] = new Attribute($row_attributes);
$variables[$section][$row_key]['cells'] = array();
$variables[$section][$row_key]['cells'] = [];
if (!empty($cells)) {
// Reset the responsive index.
$responsive_index = -1;
@ -1013,7 +1019,7 @@ function template_preprocess_table(&$variables) {
if (!is_array($cell)) {
$cell_content = $cell;
$cell_attributes = array();
$cell_attributes = [];
$is_header = FALSE;
}
else {
@ -1073,7 +1079,7 @@ function template_preprocess_table(&$variables) {
function template_preprocess_item_list(&$variables) {
$variables['wrapper_attributes'] = new Attribute($variables['wrapper_attributes']);
foreach ($variables['items'] as &$item) {
$attributes = array();
$attributes = [];
// If the item value is an array, then it is a render array.
if (is_array($item)) {
// List items support attributes via the '#wrapper_attributes' property.
@ -1112,10 +1118,10 @@ function template_preprocess_item_list(&$variables) {
}
// Set the item's value and attributes for the template.
$item = array(
$item = [
'value' => $item,
'attributes' => new Attribute($attributes),
);
];
}
}
@ -1133,7 +1139,7 @@ function template_preprocess_container(&$variables) {
$variables['has_parent'] = FALSE;
$element = $variables['element'];
// Ensure #attributes is set.
$element += array('#attributes' => array());
$element += ['#attributes' => []];
// Special handling for form elements.
if (isset($element['#array_parents'])) {
@ -1222,16 +1228,16 @@ function template_preprocess(&$variables, $hook, $info) {
*/
function _template_preprocess_default_variables() {
// Variables that don't depend on a database connection.
$variables = array(
'attributes' => array(),
'title_attributes' => array(),
'content_attributes' => array(),
'title_prefix' => array(),
'title_suffix' => array(),
$variables = [
'attributes' => [],
'title_attributes' => [],
'content_attributes' => [],
'title_prefix' => [],
'title_suffix' => [],
'db_is_active' => !defined('MAINTENANCE_MODE'),
'is_admin' => FALSE,
'logged_in' => FALSE,
);
];
// Give modules a chance to alter the default template variables.
\Drupal::moduleHandler()->alter('template_preprocess_default_variables', $variables);
@ -1296,19 +1302,19 @@ function template_preprocess_html(&$variables) {
$variables['page']['#title'] = (string) \Drupal::service('renderer')->render($variables['page']['#title']);
}
if (!empty($variables['page']['#title'])) {
$head_title = array(
$head_title = [
// Marking the title as safe since it has had the tags stripped.
'title' => Markup::create(trim(strip_tags($variables['page']['#title']))),
'name' => $site_config->get('name'),
);
];
}
// @todo Remove once views is not bypassing the view subscriber anymore.
// @see https://www.drupal.org/node/2068471
elseif ($is_front_page) {
$head_title = array(
$head_title = [
'title' => t('Home'),
'name' => $site_config->get('name'),
);
];
}
else {
$head_title = ['name' => $site_config->get('name')];
@ -1348,7 +1354,7 @@ function template_preprocess_page(&$variables) {
foreach (\Drupal::theme()->getActiveTheme()->getRegions() as $region) {
if (!isset($variables['page'][$region])) {
$variables['page'][$region] = array();
$variables['page'][$region] = [];
}
}
@ -1408,7 +1414,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') {
// page__node__1
// page__node__edit
$suggestions = array();
$suggestions = [];
$prefix = $base;
foreach ($args as $arg) {
// Remove slashes or null per SA-CORE-2009-003 and change - (hyphen) to _
@ -1423,7 +1429,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') {
// converted to underscores so here we must convert any hyphens in path
// arguments to underscores here before fetching theme hook suggestions
// to ensure the templates are appropriately recognized.
$arg = str_replace(array("/", "\\", "\0", '-'), array('', '', '', '_'), $arg);
$arg = str_replace(["/", "\\", "\0", '-'], ['', '', '', '_'], $arg);
// The percent acts as a wildcard for numeric arguments since
// asterisks are not valid filename characters on many filesystems.
if (is_numeric($arg)) {
@ -1556,7 +1562,7 @@ function template_preprocess_field(&$variables, $hook) {
// on those keys is faster than calling Element::children() or looping on all
// keys within $element, since that requires traversal of all element
// properties.
$variables['items'] = array();
$variables['items'] = [];
$delta = 0;
while (!empty($element[$delta])) {
$variables['items'][$delta]['content'] = $element[$delta];
@ -1591,31 +1597,29 @@ function template_preprocess_field_multiple_value_form(&$variables) {
if ($variables['multiple']) {
$table_id = Html::getUniqueId($element['#field_name'] . '_values');
$order_class = $element['#field_name'] . '-delta-order';
$header_attributes = new Attribute(array('class' => array('label')));
$header_attributes = new Attribute(['class' => ['label']]);
if (!empty($element['#required'])) {
$header_attributes['class'][] = 'js-form-required';
$header_attributes['class'][] = 'form-required';
}
$header = array(
array(
'data' => array(
$header = [
[
'data' => [
'#prefix' => '<h4' . $header_attributes . '>',
'title' => array(
'#markup' => $element['#title'],
),
'#markup' => $element['#title'],
'#suffix' => '</h4>',
),
],
'colspan' => 2,
'class' => array('field-label'),
),
t('Order', array(), array('context' => 'Sort order')),
);
$rows = array();
'class' => ['field-label'],
],
t('Order', [], ['context' => 'Sort order']),
];
$rows = [];
// Sort items according to '_weight' (needed when the form comes back after
// preview or failed validation).
$items = array();
$variables['button'] = array();
$items = [];
$variables['button'] = [];
foreach (Element::children($element) as $key) {
if ($key === 'add_more') {
$variables['button'] = &$element[$key];
@ -1628,40 +1632,40 @@ function template_preprocess_field_multiple_value_form(&$variables) {
// Add the items as table rows.
foreach ($items as $item) {
$item['_weight']['#attributes']['class'] = array($order_class);
$item['_weight']['#attributes']['class'] = [$order_class];
// Remove weight form element from item render array so it can be rendered
// in a separate table column.
$delta_element = $item['_weight'];
unset($item['_weight']);
$cells = array(
array('data' => '', 'class' => array('field-multiple-drag')),
array('data' => $item),
array('data' => $delta_element, 'class' => array('delta-order')),
);
$rows[] = array(
$cells = [
['data' => '', 'class' => ['field-multiple-drag']],
['data' => $item],
['data' => $delta_element, 'class' => ['delta-order']],
];
$rows[] = [
'data' => $cells,
'class' => array('draggable'),
);
'class' => ['draggable'],
];
}
$variables['table'] = array(
$variables['table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => array(
'#attributes' => [
'id' => $table_id,
'class' => array('field-multiple-table'),
),
'#tabledrag' => array(
array(
'class' => ['field-multiple-table'],
],
'#tabledrag' => [
[
'action' => 'order',
'relationship' => 'sibling',
'group' => $order_class,
),
),
);
],
],
];
if (!empty($element['#description'])) {
$description_id = $element['#attributes']['aria-describedby'];
@ -1674,7 +1678,7 @@ function template_preprocess_field_multiple_value_form(&$variables) {
}
}
else {
$variables['elements'] = array();
$variables['elements'] = [];
foreach (Element::children($element) as $key) {
$variables['elements'][] = $element[$key];
}
@ -1691,10 +1695,10 @@ function template_preprocess_field_multiple_value_form(&$variables) {
* - links: A list of \Drupal\Core\Link objects which should be rendered.
*/
function template_preprocess_breadcrumb(&$variables) {
$variables['breadcrumb'] = array();
$variables['breadcrumb'] = [];
/** @var \Drupal\Core\Link $link */
foreach ($variables['links'] as $key => $link) {
$variables['breadcrumb'][$key] = array('text' => $link->getText(), 'url' => $link->getUrl()->toString());
$variables['breadcrumb'][$key] = ['text' => $link->getText(), 'url' => $link->getUrl()->toString()];
}
}
@ -1713,39 +1717,39 @@ function _field_multiple_value_form_sort_helper($a, $b) {
* Provides theme registration for themes across .inc files.
*/
function drupal_common_theme() {
return array(
return [
// From theme.inc.
'html' => array(
'html' => [
'render element' => 'html',
),
'page' => array(
],
'page' => [
'render element' => 'page',
),
'page_title' => array(
'variables' => array('title' => NULL),
),
'region' => array(
],
'page_title' => [
'variables' => ['title' => NULL],
],
'region' => [
'render element' => 'elements',
),
'time' => array(
'variables' => array('timestamp' => NULL, 'text' => NULL, 'attributes' => array()),
),
'datetime_form' => array(
],
'time' => [
'variables' => ['timestamp' => NULL, 'text' => NULL, 'attributes' => []],
],
'datetime_form' => [
'render element' => 'element',
),
'datetime_wrapper' => array(
],
'datetime_wrapper' => [
'render element' => 'element',
),
'status_messages' => array(
],
'status_messages' => [
'variables' => ['status_headings' => [], 'message_list' => NULL],
),
'links' => array(
'variables' => array('links' => array(), 'attributes' => array('class' => array('links')), 'heading' => array(), 'set_active_class' => FALSE),
),
'dropbutton_wrapper' => array(
'variables' => array('children' => NULL),
),
'image' => array(
],
'links' => [
'variables' => ['links' => [], 'attributes' => ['class' => ['links']], 'heading' => [], 'set_active_class' => FALSE],
],
'dropbutton_wrapper' => [
'variables' => ['children' => NULL],
],
'image' => [
// HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft
// allows the alt attribute to be omitted in some cases. Therefore,
// default the alt attribute to an empty string, but allow code providing
@ -1759,107 +1763,107 @@ function drupal_common_theme() {
// - http://dev.w3.org/html5/spec/Overview.html#alt
// The title attribute is optional in all cases, so it is omitted by
// default.
'variables' => array('uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array(), 'sizes' => NULL, 'srcset' => array(), 'style_name' => NULL),
),
'breadcrumb' => array(
'variables' => array('links' => array()),
),
'table' => array(
'variables' => array('header' => NULL, 'rows' => NULL, 'footer' => NULL, 'attributes' => array(), 'caption' => NULL, 'colgroups' => array(), 'sticky' => FALSE, 'responsive' => TRUE, 'empty' => ''),
),
'tablesort_indicator' => array(
'variables' => array('style' => NULL),
),
'mark' => array(
'variables' => array('status' => MARK_NEW),
),
'item_list' => array(
'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'wrapper_attributes' => array(), 'attributes' => array(), 'empty' => NULL, 'context' => array()),
),
'feed_icon' => array(
'variables' => array('url' => NULL, 'title' => NULL),
),
'progress_bar' => array(
'variables' => array('label' => NULL, 'percent' => NULL, 'message' => NULL),
),
'indentation' => array(
'variables' => array('size' => 1),
),
'variables' => ['uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => [], 'sizes' => NULL, 'srcset' => [], 'style_name' => NULL],
],
'breadcrumb' => [
'variables' => ['links' => []],
],
'table' => [
'variables' => ['header' => NULL, 'rows' => NULL, 'footer' => NULL, 'attributes' => [], 'caption' => NULL, 'colgroups' => [], 'sticky' => FALSE, 'responsive' => TRUE, 'empty' => ''],
],
'tablesort_indicator' => [
'variables' => ['style' => NULL],
],
'mark' => [
'variables' => ['status' => MARK_NEW],
],
'item_list' => [
'variables' => ['items' => [], 'title' => '', 'list_type' => 'ul', 'wrapper_attributes' => [], 'attributes' => [], 'empty' => NULL, 'context' => []],
],
'feed_icon' => [
'variables' => ['url' => NULL, 'title' => NULL],
],
'progress_bar' => [
'variables' => ['label' => NULL, 'percent' => NULL, 'message' => NULL],
],
'indentation' => [
'variables' => ['size' => 1],
],
// From theme.maintenance.inc.
'maintenance_page' => array(
'maintenance_page' => [
'render element' => 'page',
),
'install_page' => array(
],
'install_page' => [
'render element' => 'page',
),
'maintenance_task_list' => array(
'variables' => array('items' => NULL, 'active' => NULL, 'variant' => NULL),
),
'authorize_report' => array(
],
'maintenance_task_list' => [
'variables' => ['items' => NULL, 'active' => NULL, 'variant' => NULL],
],
'authorize_report' => [
'variables' => ['messages' => [], 'attributes' => []],
'includes' => ['core/includes/theme.maintenance.inc'],
'template' => 'authorize-report',
),
],
// From pager.inc.
'pager' => array(
'pager' => [
'render element' => 'pager',
),
],
// From menu.inc.
'menu' => array(
'variables' => array('menu_name' => NULL, 'items' => array(), 'attributes' => array()),
),
'menu_local_task' => array(
'menu' => [
'variables' => ['menu_name' => NULL, 'items' => [], 'attributes' => []],
],
'menu_local_task' => [
'render element' => 'element',
),
'menu_local_action' => array(
],
'menu_local_action' => [
'render element' => 'element',
),
'menu_local_tasks' => array(
'variables' => array('primary' => array(), 'secondary' => array()),
),
],
'menu_local_tasks' => [
'variables' => ['primary' => [], 'secondary' => []],
],
// From form.inc.
'input' => array(
'input' => [
'render element' => 'element',
),
'select' => array(
],
'select' => [
'render element' => 'element',
),
'fieldset' => array(
],
'fieldset' => [
'render element' => 'element',
),
'details' => array(
],
'details' => [
'render element' => 'element',
),
'radios' => array(
],
'radios' => [
'render element' => 'element',
),
'checkboxes' => array(
],
'checkboxes' => [
'render element' => 'element',
),
'form' => array(
],
'form' => [
'render element' => 'element',
),
'textarea' => array(
],
'textarea' => [
'render element' => 'element',
),
'form_element' => array(
],
'form_element' => [
'render element' => 'element',
),
'form_element_label' => array(
],
'form_element_label' => [
'render element' => 'element',
),
'vertical_tabs' => array(
],
'vertical_tabs' => [
'render element' => 'element',
),
'container' => array(
],
'container' => [
'render element' => 'element',
),
],
// From field system.
'field' => array(
'field' => [
'render element' => 'element',
),
'field_multiple_value_form' => array(
],
'field_multiple_value_form' => [
'render element' => 'element',
),
);
],
];
}

View file

@ -11,24 +11,24 @@ use Drupal\Component\Utility\Unicode;
* Returns Unicode library status and errors.
*/
function unicode_requirements() {
$libraries = array(
$libraries = [
Unicode::STATUS_SINGLEBYTE => t('Standard PHP'),
Unicode::STATUS_MULTIBYTE => t('PHP Mbstring Extension'),
Unicode::STATUS_ERROR => t('Error'),
);
$severities = array(
];
$severities = [
Unicode::STATUS_SINGLEBYTE => REQUIREMENT_WARNING,
Unicode::STATUS_MULTIBYTE => NULL,
Unicode::STATUS_ERROR => REQUIREMENT_ERROR,
);
];
$failed_check = Unicode::check();
$library = Unicode::getStatus();
$requirements['unicode'] = array(
$requirements['unicode'] = [
'title' => t('Unicode library'),
'value' => $libraries[$library],
'severity' => $severities[$library],
);
];
switch ($failed_check) {
case 'mb_strlen':
$requirements['unicode']['description'] = t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href="http://php.net/mbstring">PHP mbstring extension</a> for improved Unicode support.');
@ -74,6 +74,11 @@ function unicode_requirements() {
* An XML parser object or FALSE on error.
*
* @ingroup php_wrappers
*
* @deprecated in Drupal 8.3.0 and will bre removed in Drupal 9.0.0. Use
* xml_parser_create() and
* xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, 'utf-8')
* instead.
*/
function drupal_xml_parser_create(&$data) {
// Default XML encoding is UTF-8
@ -92,7 +97,7 @@ function drupal_xml_parser_create(&$data) {
}
// Unsupported encodings are converted here into UTF-8.
$php_supported = array('utf-8', 'iso-8859-1', 'us-ascii');
$php_supported = ['utf-8', 'iso-8859-1', 'us-ascii'];
if (!in_array(strtolower($encoding), $php_supported)) {
$out = Unicode::convertToUtf8($data, $encoding);
if ($out !== FALSE) {
@ -100,7 +105,7 @@ function drupal_xml_parser_create(&$data) {
$data = preg_replace('/^(<\?xml[^>]+encoding)="(.+?)"/', '\\1="utf-8"', $out);
}
else {
\Drupal::logger('php')->warning('Could not convert XML encoding %s to UTF-8.', array('%s' => $encoding));
\Drupal::logger('php')->warning('Could not convert XML encoding %s to UTF-8.', ['%s' => $encoding]);
return FALSE;
}
}

View file

@ -17,7 +17,7 @@ use Drupal\Core\Utility\Error;
function update_fix_compatibility() {
$extension_config = \Drupal::configFactory()->getEditable('core.extension');
$save = FALSE;
foreach (array('module', 'theme') as $type) {
foreach (['module', 'theme'] as $type) {
foreach ($extension_config->get($type) as $name => $weight) {
if (update_check_incompatibility($name, $type)) {
$extension_config->clear("$type.$name");
@ -68,23 +68,23 @@ function update_check_incompatibility($name, $type = 'module') {
* A requirements info array.
*/
function update_system_schema_requirements() {
$requirements = array();
$requirements = [];
$system_schema = drupal_get_installed_schema_version('system');
$requirements['minimum schema']['title'] = 'Minimum schema version';
if ($system_schema >= \Drupal::CORE_MINIMUM_SCHEMA_VERSION) {
$requirements['minimum schema'] += array(
$requirements['minimum schema'] += [
'value' => 'The installed schema version meets the minimum.',
'description' => 'Schema version: ' . $system_schema,
);
];
}
else {
$requirements['minimum schema'] += array(
$requirements['minimum schema'] += [
'value' => 'The installed schema version does not meet the minimum.',
'severity' => REQUIREMENT_ERROR,
'description' => 'Your system schema version is ' . $system_schema . '. Updating directly from a schema version prior to 8000 is not supported. You must <a href="https://www.drupal.org/node/2179269">migrate your site to Drupal 8</a> first.',
);
];
}
return $requirements;
@ -95,7 +95,7 @@ function update_system_schema_requirements() {
*/
function update_check_requirements() {
// Check requirements of all loaded modules.
$requirements = \Drupal::moduleHandler()->invokeAll('requirements', array('update'));
$requirements = \Drupal::moduleHandler()->invokeAll('requirements', ['update']);
$requirements += update_system_schema_requirements();
return $requirements;
}
@ -168,11 +168,11 @@ function update_do_one($module, $number, $dependency_map, &$context) {
// If this update was aborted in a previous step, or has a dependency that
// was aborted in a previous step, go no further.
if (!empty($context['results']['#abort']) && array_intersect($context['results']['#abort'], array_merge($dependency_map, array($function)))) {
if (!empty($context['results']['#abort']) && array_intersect($context['results']['#abort'], array_merge($dependency_map, [$function]))) {
return;
}
$ret = array();
$ret = [];
if (function_exists($function)) {
try {
$ret['results']['query'] = $function($context['sandbox']);
@ -187,7 +187,7 @@ function update_do_one($module, $number, $dependency_map, &$context) {
$variables = Error::decodeException($e);
unset($variables['backtrace']);
$ret['#abort'] = array('success' => FALSE, 'query' => t('%type: @message in %function (line %line of %file).', $variables));
$ret['#abort'] = ['success' => FALSE, 'query' => t('%type: @message in %function (line %line of %file).', $variables)];
}
}
@ -197,10 +197,10 @@ function update_do_one($module, $number, $dependency_map, &$context) {
}
if (!isset($context['results'][$module])) {
$context['results'][$module] = array();
$context['results'][$module] = [];
}
if (!isset($context['results'][$module][$number])) {
$context['results'][$module][$number] = array();
$context['results'][$module][$number] = [];
}
$context['results'][$module][$number] = array_merge($context['results'][$module][$number], $ret);
@ -266,7 +266,7 @@ function update_invoke_post_update($function, &$context) {
unset($context['sandbox']['#finished']);
}
if (!isset($context['results'][$module][$name])) {
$context['results'][$module][$name] = array();
$context['results'][$module][$name] = [];
}
$context['results'][$module][$name] = array_merge($context['results'][$module][$name], $ret);
@ -298,7 +298,7 @@ function update_invoke_post_update($function, &$context) {
*/
function update_get_update_list() {
// Make sure that the system module is first in the list of updates.
$ret = array('system' => array());
$ret = ['system' => []];
$modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
foreach ($modules as $module => $schema_version) {
@ -332,7 +332,7 @@ function update_get_update_list() {
if ($update > $schema_version) {
// The description for an update comes from its Doxygen.
$func = new ReflectionFunction($module . '_update_' . $update);
$description = str_replace(array("\n", '*', '/'), '', $func->getDocComment());
$description = str_replace(["\n", '*', '/'], '', $func->getDocComment());
$ret[$module]['pending'][$update] = "$update - $description";
if (!isset($ret[$module]['start'])) {
$ret[$module]['start'] = $update;
@ -400,7 +400,7 @@ function update_resolve_dependencies($starting_updates) {
// Perform the depth-first search and sort on the results.
$graph_object = new Graph($graph);
$graph = $graph_object->searchAndSort();
uasort($graph, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
uasort($graph, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
foreach ($graph as $function => &$data) {
$module = $data['module'];
@ -416,7 +416,7 @@ function update_resolve_dependencies($starting_updates) {
}
elseif (!isset($data['allowed'])) {
$data['allowed'] = TRUE;
$data['missing_dependencies'] = array();
$data['missing_dependencies'] = [];
}
// Now that we have finished processing this function, remove it from the
// graph if it was not part of the original list. This ensures that we
@ -448,9 +448,9 @@ function update_resolve_dependencies($starting_updates) {
function update_get_update_function_list($starting_updates) {
// Go through each module and find all updates that we need (including the
// first update that was requested and any updates that run after it).
$update_functions = array();
$update_functions = [];
foreach ($starting_updates as $module => $version) {
$update_functions[$module] = array();
$update_functions[$module] = [];
$updates = drupal_get_schema_versions($module);
if ($updates !== FALSE) {
$max_version = max($updates);
@ -512,7 +512,7 @@ function update_get_update_function_list($starting_updates) {
function update_build_dependency_graph($update_functions) {
// Initialize an array that will define a directed graph representing the
// dependencies between update functions.
$graph = array();
$graph = [];
// Go through each update function and build an initial list of dependencies.
foreach ($update_functions as $module => $functions) {
@ -600,7 +600,7 @@ function update_already_performed($module, $number) {
* @see hook_update_dependencies()
*/
function update_retrieve_dependencies() {
$return = array();
$return = [];
// Get a list of installed modules, arranged so that we invoke their hooks in
// the same order that \Drupal::moduleHandler()->invokeAll() does.
foreach (\Drupal::keyValue('system.schema')->getAll() as $module => $schema) {
@ -675,7 +675,7 @@ function update_replace_permissions($replace) {
foreach ($role_names as $role_name) {
$rid = substr($role_name, $cut);
$config = \Drupal::config("user.role.$rid");
$permissions = $config->get('permissions') ?: array();
$permissions = $config->get('permissions') ?: [];
foreach ($replace as $old_permission => $new_permissions) {
if (($index = array_search($old_permission, $permissions)) !== FALSE) {
unset($permissions[$index]);
@ -687,78 +687,3 @@ function update_replace_permissions($replace) {
->save();
}
}
/**
* Returns a list of languages set up on the site during upgrades.
*
* @param $flags
* (optional) Specifies the state of the languages that have to be returned.
* It can be: LanguageInterface::STATE_CONFIGURABLE,
* LanguageInterface::STATE_LOCKED, or LanguageInterface::STATE_ALL.
*
* @return \Drupal\Core\Language\LanguageInterface[]
* An associative array of languages, keyed by the language code, ordered by
* weight ascending and name ascending.
*/
function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) {
$languages = &drupal_static(__FUNCTION__);
// Initialize master language list.
if (!isset($languages)) {
// Initialize local language list cache.
$languages = array();
// Fill in master language list based on current configuration.
$default = \Drupal::languageManager()->getDefaultLanguage();
if (\Drupal::languageManager()->isMultilingual() || \Drupal::moduleHandler()->moduleExists('language')) {
// Use language module configuration if available. We can not use
// entity_load_multiple() because this breaks during updates.
$language_entities = \Drupal::configFactory()->listAll('language.entity.');
// Initialize default property so callers have an easy reference and can
// save the same object without data loss.
foreach ($language_entities as $langcode_config_name) {
$langcode = substr($langcode_config_name, strlen('language.entity.'));
$info = \Drupal::config($langcode_config_name)->get();
$languages[$langcode] = new Language(array(
'default' => ($info['id'] == $default->getId()),
'name' => $info['label'],
'id' => $info['id'],
'direction' => $info['direction'],
'locked' => $info['locked'],
'weight' => $info['weight'],
));
}
Language::sort($languages);
}
else {
// No language module, so use the default language only.
$languages = array($default->getId() => $default);
// Add the special languages, they will be filtered later if needed.
$languages += \Drupal::languageManager()->getDefaultLockedLanguages($default->getWeight());
}
}
// Filter the full list of languages based on the value of the $all flag. By
// default we remove the locked languages, but the caller may request for
// those languages to be added as well.
$filtered_languages = array();
// Add the site's default language if flagged as allowed value.
if ($flags & LanguageInterface::STATE_SITE_DEFAULT) {
$default = \Drupal::languageManager()->getDefaultLanguage();
// Rename the default language.
$default->setName(t("Site's default language (@lang_name)", array('@lang_name' => $default->getName())));
$filtered_languages[LanguageInterface::LANGCODE_SITE_DEFAULT] = $default;
}
foreach ($languages as $langcode => $language) {
if (($language->isLocked() && !($flags & LanguageInterface::STATE_LOCKED)) || (!$language->isLocked() && !($flags & LanguageInterface::STATE_CONFIGURABLE))) {
continue;
}
$filtered_languages[$langcode] = $language;
}
return $filtered_languages;
}

View file

@ -9,19 +9,20 @@ use Drupal\Core\PhpStorage\PhpStorageFactory;
use Drupal\Core\Cache\Cache;
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
use Composer\Autoload\ClassLoader;
/**
* Rebuilds all caches even when Drupal itself does not work.
*
* @param \Composer\Autoload\ClassLoader $class_loader
* The class loader.
* @param $class_loader
* The class loader. Normally Composer's ClassLoader, as included by the
* front controller, but may also be decorated; e.g.,
* \Symfony\Component\ClassLoader\ApcClassLoader, \Symfony\Component\ClassLoader\WinCacheClassLoader, or \Symfony\Component\ClassLoader\XcacheClassLoader
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @see rebuild.php
*/
function drupal_rebuild(ClassLoader $class_loader, Request $request) {
function drupal_rebuild($class_loader, Request $request) {
// Remove Drupal's error and exception handlers; they rely on a working
// service container and other subsystems and will only cause a fatal error
// that hides the actual error.