Commit 8f44f19c authored by Rahul Gupta's avatar Rahul Gupta Committed by Ted Bowman
Browse files

Issue #3310666 by tedbow, kunal.sachdev, rahul_, phenaproxima, Shabbir,...

Issue #3310666 by tedbow, kunal.sachdev, rahul_, phenaproxima, Shabbir, siramsay: UpdaterForm throws an exception if you try to update to the next minor beta
parent f37eed53
Loading
Loading
Loading
Loading
+77 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
Contains metadata about the following (fake) releases of Drupal core, in order:
* 9.8.0-beta1
* 9.7.0
* 9.8.x-dev
-->
<project xmlns:dc="http://purl.org/dc/elements/1.1/">
    <title>Drupal</title>
    <short_name>drupal</short_name>
    <dc:creator>Drupal</dc:creator>
    <supported_branches>9.8.,9.7.</supported_branches>
    <project_status>published</project_status>
    <link>http://example.com/project/drupal</link>
    <terms>
        <term>
            <name>Projects</name>
            <value>Drupal project</value>
        </term>
    </terms>
    <releases>
        <release>
          <name>Drupal 9.8.0-beta1</name>
          <version>9.8.0-beta1</version>
          <status>published</status>
          <release_link>http://example.com/drupal-9-8-0-beta1-release</release_link>
          <download_link>http://example.com/drupal-9-8-0-beta1-.tar.gz</download_link>
          <date>1250424521</date>
          <terms>
            <term>
              <name>Release type</name>
              <value>New features</value>
            </term>
            <term>
              <name>Release type</name>
              <value>Bug fixes</value>
            </term>
          </terms>
        </release>
        <release>
            <name>Drupal 9.7.0</name>
            <version>9.7.0</version>
            <status>published</status>
            <release_link>http://example.com/drupal-9-7-0-release</release_link>
            <download_link>http://example.com/drupal-9-7-0.tar.gz</download_link>
            <date>1250424521</date>
            <terms>
                <term>
                    <name>Release type</name>
                    <value>New features</value>
                </term>
                <term>
                    <name>Release type</name>
                    <value>Bug fixes</value>
                </term>
            </terms>
        </release>
        <release>
            <name>Drupal 9.8.x-dev</name>
            <version>9.8.x-dev</version>
            <status>published</status>
            <release_link>http://example.com/drupal-9-8-x-dex-release</release_link>
            <download_link>http://example.com/drupal-9-8-x-dex.tar.gz</download_link>
            <date>1250424521</date>
            <terms>
                <term>
                    <name>Release type</name>
                    <value>New features</value>
                </term>
                <term>
                    <name>Release type</name>
                    <value>Bug fixes</value>
                </term>
            </terms>
        </release>
    </releases>
</project>
+18 −8
Original line number Diff line number Diff line
@@ -314,18 +314,28 @@ final class UpdaterForm extends UpdateFormBase {
        $first_release_version = $release_version->getMajorVersion() . '.' . $release_version->getMinorVersion() . '.0';
        $available_updates = update_get_available(TRUE);

        // @todo In https://www.drupal.org/i/3310666 handle if the .0 release is
        //   not available, and only pre-releases are available.
        // If the `.0` patch release of this minor is available link to its
        // release notes because this will document the most important changes
        // in this minor.
        if (isset($available_updates['drupal']['releases'][$first_release_version])) {
          $next_minor_first_release = ProjectRelease::createFromArray($available_updates['drupal']['releases'][$first_release_version]);
          $caption = $this->t('Latest version of Drupal @major.@minor (next minor) (<a href=":url">Release notes</a>):', [
            '@major' => $release_version->getMajorVersion(),
            '@minor' => $release_version->getMinorVersion(),
            ':url' => $next_minor_first_release->getReleaseUrl(),
          ]);
        }
        else {
          $caption = $this->t('Latest version of Drupal @major.@minor (next minor):', [
            '@major' => $release_version->getMajorVersion(),
            '@minor' => $release_version->getMinorVersion(),
          ]);
        }

        $form["next_minor_$next_minor_release_count"] = $this->createReleaseTable(
          $release,
          $installed_minor_release ? $this->t('Minor update') : $release_status,
          $this->t('Latest version of Drupal @major.@minor (next minor) (<a href=":url">Release notes</a>):', [
            '@major' => $release_version->getMajorVersion(),
            '@minor' => $release_version->getMinorVersion(),
            ':url' => $next_minor_first_release->getReleaseUrl(),
          ]),
          $caption,
          $installed_minor_release ? 'update-optional' : $type,
          $create_update_buttons,
          $is_primary
+16 −0
Original line number Diff line number Diff line
@@ -259,6 +259,22 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
    $assert_session->pageTextContains($message);
  }

  /**
   * Checks pre-releases of the next minor are available on the form.
   */
  public function testNextMinorPreRelease(): void {
    $this->setReleaseMetadata(__DIR__ . '/../../../package_manager/tests/fixtures/release-history/drupal.9.8.0-beta1.xml');
    $this->setCoreVersion('9.7.0');
    $this->config('automatic_updates.settings')
      ->set('allow_core_minor_updates', TRUE)
      ->save();
    $this->checkForUpdates();
    $this->drupalGet('/admin/reports/updates/automatic-update');
    $assert_session = $this->assertSession();
    $this->checkReleaseTable('#edit-next-minor-1', '.update-update-recommended', '9.8.0-beta1', FALSE, 'Latest version of Drupal 9.8 (next minor):');
    $assert_session->pageTextContainsOnce('Currently installed: 9.7.0 (Up to date)');
  }

  /**
   * Checks the table for a release on the form.
   *