Unverified Commit 052816d2 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3014051 by tedbow, mitrpaka, govind.maloo, Suresh Prabhu Parkala,...

Issue #3014051 by tedbow, mitrpaka, govind.maloo, Suresh Prabhu Parkala, tim.plunkett, phenaproxima: Update module does not depend on the File Module
parent 83171724
Loading
Loading
Loading
Loading
+11 −1
Changes for core/modules/update/src/Form/UpdateManagerInstall.php: 11 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -111,6 +111,8 @@ public function buildForm(array $form, FormStateInterface $form_state) {
      '#description' => $this->t('For example: %url', ['%url' => 'https://ftp.drupal.org/files/projects/name.tar.gz']),
    ];

    // Provide upload option only if file module exists.
    if ($this->moduleHandler->moduleExists('file')) {
      $form['information'] = [
        '#prefix' => '<strong>',
        '#markup' => $this->t('Or'),
@@ -122,6 +124,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
        '#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,10 +141,17 @@ public function buildForm(array $form, FormStateInterface $form_state) {
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    $all_files = $this->getRequest()->files->get('files', []);
    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.'));
      }
    }
  }

  /**
   * {@inheritdoc}
@@ -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
+1 −1
Changes for core/modules/update/tests/src/Functional/UpdateUploadTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ class UpdateUploadTest extends UpdateTestBase {
   *
   * @var array
   */
  protected static $modules = ['update', 'update_test'];
  protected static $modules = ['update', 'update_test', 'file'];

  /**
   * {@inheritdoc}
+0 −2
Changes for core/modules/update/update.info.yml: 0 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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
+2 −5
Changes for core/tests/Drupal/FunctionalTests/Installer/TestingProfileInstallTest.php: 2 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -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'));
  }

  /**