diff --git a/core/modules/update/src/Form/UpdateManagerInstall.php b/core/modules/update/src/Form/UpdateManagerInstall.php index b7afcbad7652be6bcc35f39a5664339469c6ef25..92d3b4f65ebf1795ecaa78ae1b6b5d77a1b89b2a 100644 --- a/core/modules/update/src/Form/UpdateManagerInstall.php +++ b/core/modules/update/src/Form/UpdateManagerInstall.php @@ -111,17 +111,20 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#description' => $this->t('For example: %url', ['%url' => 'https://ftp.drupal.org/files/projects/name.tar.gz']), ]; - $form['information'] = [ - '#prefix' => '<strong>', - '#markup' => $this->t('Or'), - '#suffix' => '</strong>', - ]; - - $form['project_upload'] = [ - '#type' => 'file', - '#title' => $this->t('Upload a module or theme archive'), - '#description' => $this->t('For example: %filename from your local computer', ['%filename' => 'name.tar.gz']), - ]; + // Provide upload option only if file module exists. + if ($this->moduleHandler->moduleExists('file')) { + $form['information'] = [ + '#prefix' => '<strong>', + '#markup' => $this->t('Or'), + '#suffix' => '</strong>', + ]; + + $form['project_upload'] = [ + '#type' => 'file', + '#title' => $this->t('Upload a module or theme archive'), + '#description' => $this->t('For example: %filename from your local computer', ['%filename' => 'name.tar.gz']), + ]; + } $form['actions'] = ['#type' => 'actions']; $form['actions']['submit'] = [ @@ -138,8 +141,15 @@ public function buildForm(array $form, FormStateInterface $form_state) { */ public function validateForm(array &$form, FormStateInterface $form_state) { $all_files = $this->getRequest()->files->get('files', []); - if (!($form_state->getValue('project_url') xor !empty($all_files['project_upload']))) { - $form_state->setErrorByName('project_url', $this->t('You must either provide a URL or upload an archive file.')); + if ($this->moduleHandler->moduleExists('file')) { + if (!($form_state->getValue('project_url') xor !empty($all_files['project_upload']))) { + $form_state->setErrorByName('project_url', $this->t('You must either provide a URL or upload an archive file.')); + } + } + else { + if (!($form_state->getValue('project_url'))) { + $form_state->setErrorByName('project_url', $this->t('You must provide a URL to install.')); + } } } @@ -156,7 +166,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { return; } } - elseif (!empty($all_files['project_upload'])) { + elseif (!empty($all_files['project_upload']) && $this->moduleHandler->moduleExists('file')) { $validators = ['file_validate_extensions' => [$this->archiverManager->getExtensions()]]; if (!($finfo = file_save_upload('project_upload', $validators, NULL, 0, FileSystemInterface::EXISTS_REPLACE))) { // Failed to upload the file. file_save_upload() calls diff --git a/core/modules/update/tests/src/Functional/UpdateUploadTest.php b/core/modules/update/tests/src/Functional/UpdateUploadTest.php index 268598a1ad0d6c0c27856722822668aa914bccfb..57dee623083042036a369f6b72cd20350127e89b 100644 --- a/core/modules/update/tests/src/Functional/UpdateUploadTest.php +++ b/core/modules/update/tests/src/Functional/UpdateUploadTest.php @@ -23,7 +23,7 @@ class UpdateUploadTest extends UpdateTestBase { * * @var array */ - protected static $modules = ['update', 'update_test']; + protected static $modules = ['update', 'update_test', 'file']; /** * {@inheritdoc} diff --git a/core/modules/update/update.info.yml b/core/modules/update/update.info.yml index 0c363f44c28e739281aacfd7d5727f90a4683627..f095c04f5f6fd575f901dcae8773021dccb0a172 100644 --- a/core/modules/update/update.info.yml +++ b/core/modules/update/update.info.yml @@ -4,5 +4,3 @@ description: 'Checks for available updates, and can securely install or update m version: VERSION package: Core configure: update.settings -dependencies: - - drupal:file diff --git a/core/tests/Drupal/FunctionalTests/Installer/TestingProfileInstallTest.php b/core/tests/Drupal/FunctionalTests/Installer/TestingProfileInstallTest.php index b358787ba98d5f20313718bb91c3d335fc0af39b..4c98bfd5536e8c5afc33805cedccfb053c8ea5bb 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/TestingProfileInstallTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/TestingProfileInstallTest.php @@ -22,13 +22,10 @@ class TestingProfileInstallTest extends BrowserTestBase { protected $defaultTheme = 'stark'; /** - * Ensure the Update module and its dependencies are installed. + * Ensure the Update module is installed. */ public function testUpdateModuleInstall() { - $this->assertTrue( - \Drupal::moduleHandler()->moduleExists('update') && \Drupal::moduleHandler()->moduleExists('file') && \Drupal::moduleHandler()->moduleExists('field'), - 'The Update module and its dependencies are installed.' - ); + $this->assertTrue(\Drupal::moduleHandler()->moduleExists('update')); } /**