Update to Drupal 8.1.8. For more information, see https://www.drupal.org/project/drupal/releases/8.1.8
This commit is contained in:
parent
e9f047ccf8
commit
f9f23cdf38
312 changed files with 6751 additions and 1546 deletions
31
core/modules/config/config.install
Normal file
31
core/modules/config/config.install
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the config module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_requirements().
|
||||
*/
|
||||
function config_requirements($phase) {
|
||||
$requirements = [];
|
||||
try {
|
||||
$directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
// system_requirements() guarantees that the CONFIG_SYNC_DIRECTORY exists
|
||||
// as the config.storage.staging service relies on it.
|
||||
$directory = FALSE;
|
||||
}
|
||||
// Ensure the configuration sync directory is writable. This is only a warning
|
||||
// because only configuration import from a tarball requires the folder to be
|
||||
// web writable.
|
||||
if ($phase !== 'install' && !is_writable($directory)) {
|
||||
$requirements['config directory ' . CONFIG_SYNC_DIRECTORY] = [
|
||||
'title' => t('The directory %directory is not writable.', ['%directory' => $directory]),
|
||||
'severity' => REQUIREMENT_WARNING,
|
||||
];
|
||||
}
|
||||
return $requirements;
|
||||
}
|
|
@ -50,6 +50,11 @@ class ConfigImportForm extends FormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
|
||||
$directory_is_writable = is_writable($directory);
|
||||
if (!$directory_is_writable) {
|
||||
drupal_set_message($this->t('The directory %directory is not writable.', ['%directory' => $directory]), 'error');
|
||||
}
|
||||
$form['import_tarball'] = array(
|
||||
'#type' => 'file',
|
||||
'#title' => $this->t('Configuration archive'),
|
||||
|
@ -59,6 +64,7 @@ class ConfigImportForm extends FormBase {
|
|||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Upload'),
|
||||
'#disabled' => !$directory_is_writable,
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,16 @@ class ConfigImportUploadTest extends WebTestBase {
|
|||
$edit = array('files[import_tarball]' => drupal_realpath($text_file->uri));
|
||||
$this->drupalPostForm('admin/config/development/configuration/full/import', $edit, t('Upload'));
|
||||
$this->assertText(t('Could not extract the contents of the tar file'));
|
||||
|
||||
// Make the sync directory read-only.
|
||||
$directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
|
||||
\Drupal::service('file_system')->chmod($directory, 0555);
|
||||
$this->drupalGet('admin/config/development/configuration/full/import');
|
||||
$this->assertRaw(t('The directory %directory is not writable.', ['%directory' => $directory]));
|
||||
// Ensure submit button for \Drupal\config\Form\ConfigImportForm is
|
||||
// disabled.
|
||||
$submit_is_disabled = $this->cssSelect('form.config-import-form input[type="submit"]:disabled');
|
||||
$this->assertTrue(count($submit_is_disabled) === 1, 'The submit button is disabled.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class ConfigInstallWebTest extends WebTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->adminUser = $this->drupalCreateUser(array('administer modules', 'administer themes'));
|
||||
$this->adminUser = $this->drupalCreateUser(array('administer modules', 'administer themes', 'administer site configuration'));
|
||||
|
||||
// Ensure the global variable being asserted by this test does not exist;
|
||||
// a previous test executed in this request/process might have set it.
|
||||
|
@ -188,4 +188,22 @@ class ConfigInstallWebTest extends WebTestBase {
|
|||
$this->assertTrue(entity_load('config_test', 'other_module_test_with_dependency'), 'The config_test.dynamic.other_module_test_with_dependency configuration has been created during install.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests config_requirements().
|
||||
*/
|
||||
public function testConfigModuleRequirements() {
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$this->drupalPostForm('admin/modules', array('modules[Core][config][enable]' => TRUE), t('Install'));
|
||||
|
||||
$directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
|
||||
file_unmanaged_delete_recursive($directory);
|
||||
$this->drupalGet('/admin/reports/status');
|
||||
$this->assertRaw(t('The directory %directory does not exist.', array('%directory' => $directory)));
|
||||
|
||||
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
|
||||
\Drupal::service('file_system')->chmod($directory, 0555);
|
||||
$this->drupalGet('/admin/reports/status');
|
||||
$this->assertRaw(t('The directory %directory is not writable.', ['%directory' => $directory]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ entity.config_test.edit_form:
|
|||
requirements:
|
||||
_permission: 'administer site configuration'
|
||||
|
||||
entity.config_test.edit_form_config_test_no_status:
|
||||
entity.config_test_no_status.edit_form:
|
||||
path: '/admin/structure/config_test/manage/{config_test_no_status}'
|
||||
defaults:
|
||||
_entity_form: config_test_no_status
|
||||
|
|
Reference in a new issue