Problem/Motivation

Currently as of the time of creating this issue, the latest version of Drupal is 9.4.5. My current site (for which I am using this module) is also running on 9.4.5, the current beta version of Drupal core is drupal 9.5.0-beta1. The updates tab gives an error

LogicException: Release information for Drupal 9.5.0 is not available. in Drupal\automatic_updates\Form\UpdaterForm->buildForm() (line 264 of modules/contrib/automatic_updates/src/Form/UpdaterForm.php).

Steps to reproduce

1. Make sure your Drupal installation's core version is upto date to the latest version of Drupal core (from Drupal.org)
2. Change the settings in settings.php to True with this code $config['automatic_updates.settings']['allow_core_minor_updates'] = TRUE; and try to test the updates from the updates tab
3. Goto "admin/reports/updates/automatic-update" and you will find the issue

I have attached the screenshot of the error as well.

Proposed resolution

Right now, UpdaterForm throws the exception if the release doesn't exist.

in the current example, showing the next minor 9.5.0-beta1, it is not a problem that 9.5.0 doesn't exist, it should not. if we showing the update to 9.5.1, or any 9.5.x that is greater than 9.5.0 it would be problem that 9.5.0 does not exist. That should never happen.

So we need to check if $next_minor_version > $first_release_version using \Composer\Semver\Semver::satisfies then \Drupal\automatic_updates\Form\UpdaterForm::createReleaseTable() will not need a link in the $caption argument.

if $next_minor_version < $first_release_version then we can still through the logic error because we should always have the release

CommentFileSizeAuthor
Screenshot 2022-09-20 at 16.11.48.png333.17 KBshabbir
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Shabbir created an issue. See original summary.

tedbow’s picture

ok this is because

$first_release_version = $next_minor_version->getMajorVersion() . '.' . $next_minor_version->getMinorVersion() . '.0';

will get 9.5.0 but that is not released yet. so we can't make this link if the first stable release of the major is not out

phenaproxima’s picture

At the very least we should catch the exception.

shabbir’s picture

Title: Error on updating to beta version » [DrupalCon Prague] Error on updating to beta version
phenaproxima’s picture

Looking at this, I think this shouldn't be an exception. We should just flag a warning message if release notes are not available.

phenaproxima’s picture

Issue summary: View changes

Added a proposed resolution.

phenaproxima’s picture

Title: [DrupalCon Prague] Error on updating to beta version » UpdaterForm throws an exception if you try to update to the next minor beta
Issue tags: +Prague2022

Re-titling for clarity.

rahul_ made their first commit to this issue’s fork.

rahul_’s picture

Assigned: Unassigned » rahul_
Status: Active » Needs review

tedbow’s picture

Issue summary: View changes

Looking at this, I think this shouldn't be an exception. We should just flag a warning message if release notes are not available.

In this case I don't think we need a warning.

basically originally in #3291730: When displaying updates in the next minor, show a link to the relevant major.minor.0 release notes the idea was if you are updating from 9.4.6 to 9.5.6(or anything above 9.5.0) you should also see a link to 9.5.0 because this is where the big changes between 9.4.x and 9.5.x will be documented.

but if you latest in 9.5.x is only a pre-release, 9.5.0-beta1 for example, then 9.5.0 will not exist so there is no need to show any other release notes beside 9.5.0-beta1. so in that case we don't need to have link in the table caption. so \Drupal\automatic_updates\Form\UpdaterForm::createReleaseTable() will not need a link in the $caption argument

phenaproxima’s picture

Discussing this with @tedbow on Zoom, this is what we agreed on as the right solution here.

First of all, this issue is only about what to do when generating the table caption that is shown above the table where you see the update to the next minor. No other part of the form should be affected.

Here's the logic we think we should do:

If the target version of core is greater than -- NOT greater or equal -- the .0 release of the next minor, the caption should link to the release notes for the MAJOR.MINOR.0 release. If we cannot get those release notes (i.e., the release is unavailable), that's an error condition and should raise a LogicException.

In any other situation, don't link to the release notes in the caption. They are already linked in the table itself.

In pseudocode (this is here merely as guidance, it won't work if used directly):

if ($next_minor_release) {
  $next_minor_version = ExtensionVersion::createFromVersionString($next_minor_release->getVersion());
  $first_release_version = $next_minor_version->getMajorVersion() . '.' . $next_minor_version->getMinorVersion() . '.0';

  $caption = $this->t('Latest version of Drupal @major.@minor (next minor)', [...]);
  if (Composer\Semver\Comparator::greaterThan($next_minor_release->getVersion(), $first_release_version)) {
    if (empty($available_updates['drupal']['releases'][$first_release_version])) {
      throw new \LogicException();
    }
    $next_minor_first_release = ProjectRelease::createFromArray($available_updates['drupal']['releases'][$first_release_version]);
    $caption = $this->t('@caption (<a href=":url">Release notes</a>):', ['@caption' => $caption, ':url' => $next_minor_first_release->getReleaseUrl()]);
  }

  $form['next_minor'] = $this->createReleaseTable($next_minor_release, $installed_minor_release ? $this->t('Minor update') : $release_status, $caption, ...);
}
phenaproxima’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
siramsay’s picture

I can verify this issue. I got the white screen with "The website encountered an unexpected error. Please try again later" and the below message in the logs and ended up here.

LogicException: Release information for Drupal 9.5.0 is not available. in Drupal\automatic_updates\Form\UpdaterForm->buildForm() (line 264 of /var/www/digikojo.com/public_html/drupal_auto4/web/modules/contrib/automatic_updates/src/Form/UpdaterForm.php).

I manually patched my version of Automatic Updates with the code from here https://git.drupalcode.org/issue/automatic_updates-3310666/-/compare/8.x...

This worked, I was able to update from 9.4.5 to 9.4.7 (with the option to update to 9.5.0-beta2)

phenaproxima’s picture

Assigned: rahul_ » phenaproxima

@rahul_ asked me to take this on.

kunal.sachdev made their first commit to this issue’s fork.

kunal.sachdev’s picture

Status: Needs work » Needs review
phenaproxima’s picture

Assigned: phenaproxima » Unassigned
Status: Needs review » Needs work
Issue tags: -Needs tests

I think we've got our bases covered for tests. Just a few small requests and then I'm happy.

kunal.sachdev’s picture

Status: Needs work » Needs review
phenaproxima’s picture

Assigned: Unassigned » tedbow

I'm happy with this; assigning to @tedbow for final review and commit.

One thing I wonder: do we maybe want test coverage to confirm that the exception is thrown if, for some reason, we can't get release info for the x.y.0 release? I don't think we had any such coverage before, so I don't know if that should block commit, but thought I'd raise the question.

tedbow’s picture

Status: Needs review » Needs work
tedbow’s picture

ok the reason the tests are currently failing is because is in \Drupal\package_manager\ProjectInfo::getInstallableReleases if the update module considers the project "current" we don't return any releases. But the update module will consider the project "current" if there the only newer releases in the current major are pre-releases.

we need to solve this problem first #3310696: if only newer releases are pre-releases Updating from one minor to latest version Drupal version, module does not show any other updates

tedbow’s picture

crediting @siramsay for testing the issue

tedbow’s picture

Status: Needs work » Reviewed & tested by the community

I think this is good. Will merge if green

  • tedbow committed 8f44f19 on 8.x-2.x authored by rahul_
    Issue #3310666 by tedbow, kunal.sachdev, rahul_, phenaproxima, Shabbir,...
tedbow’s picture

Thanks everyone!

tedbow’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

tedbow’s picture

Issue tags: +core-mvp