Skip to content
Snippets Groups Projects

Issue #3303929: Never allow updating to an un-installable version

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 automatic_updates_extensions_tests:
  • added 1 commit

    • 0e5078ec - began hook_update_status_alter:

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • 4 * @file
    5 * Contains hook implementation for Automatic Updates Extensions.
    6 */
    7
    8 use Drupal\update\UpdateFetcherInterface;
    9
    10 /**
    11 * Alter the information about available updates for projects.
    12 *
    13 * @param $projects
    14 * Reference to an array of information about available updates to each
    15 * project installed on the system.
    16 *
    17 * @see update_calculate_project_data()
    18 */
    19 function automatic_updates_update_status_alter(&$projects) {
    • This function name is wrong for implementing the hook.

      since your info.yml file is automatic_updates_extensions_test_update.info.yml the machine name of your module is automatic_updates_extensions_test_update

      so you would implement hook_update_status_alter by creating the function automatic_updates_extensions_test_update_update_status_alter basically machine_name_of_module + (name of hook without "hook_"

      So in this case:

      automatic_updates_extensions_test+ update_status_alter = automatic_updates_extensions_test_update_update_status_alter

      hooks are weird.

      The code may be working now but that is only because you are using the machine of another module automatic_updates so it only works because automatic_updates is not implementing hook_update_status_alter and if it did this code would break.

      Edited by Ted Bowman
    • Theresa Grannum changed this line in version 5 of the diff

      changed this line in version 5 of the diff

    • Please register or sign in to reply
  • added 1 commit

    • d783e706 - correct name of hook_update_status_alter()

    Compare with previous version

  • added 1 commit

    • cb8a73b4 - correct name of hook_update_status_alter()

    Compare with previous version

  • added 1 commit

    • b4a1b697 - began building hook function and ran checks

    Compare with previous version

  • 1 name: 'Automatic Updates Extensions Tests'
  • 3 /**
    4 * @file
    5 * Contains hook implementation for Automatic Updates Extensions.
    6 */
    7
    8 /**
    9 * Alter the information about available updates for projects.
    10 *
    11 * @param $projects
    12 * Reference to an array of information about available updates to each
    13 * project installed on the system.
    14 *
    15 * @see update_calculate_project_data()
    16 */
    17 function automatic_updates_extensions_test_update_update_status_alter(&$projects) {
    18 if (!empty($projects['semver_test'])) {
    • The fact that our tests are failing means that this is changing the recommended version which is good. But we only want to do this in the new test method testUninstallableRelease runs.

      So we need to set a state flag to only do this when testUninstallableRelease runs

      So at the first of \Drupal\Tests\automatic_updates_extensions\Functional\UpdaterFormTest::testUninstallableRelease() add

      $this->container->get('state')->set('testUninstallableRelease', TRUE);

      then here change this to

      Suggested change
      18 if (!empty($projects['semver_test'])) {
      18 if (\Drupal::state()->get('testUninstallableRelease') && !empty($projects['semver_test'])) {

      This way this will only check affect the 1 test.

      then at the end of testUninstallableRelease instead of assert the update is available do $this->assertNoUpdates();

      This should fail now proving the current bug but then we update \Drupal\automatic_updates_extensions\Form\UpdaterForm::getRecommendedModuleUpdates to make the sure the recommended release is in \Drupal\automatic_updates\ProjectInfo::getInstallableReleases which fix the bug it will start to pass again.

    • Theresa Grannum changed this line in version 8 of the diff

      changed this line in version 8 of the diff

    • Please register or sign in to reply
  • Theresa Grannum added 5 commits

    added 5 commits

    • c9dad826 - refactored module folder name
    • 41d3caa5 - renamed hook function
    • 90033e24 - per feedback added state flag to set changes to only apply for testUnistallableRelease
    • 69341d4a - adjusted if statement
    • 68d4a1c9 - ran checks

    Compare with previous version

  • added 1 commit

    • 18f5e782 - did not update to call new module name

    Compare with previous version

  • added 1 commit

    • 12729371 - assert noUpdate available for test

    Compare with previous version

  • Ted Bowman
  • 1 <?php
    2
    3 /**
    4 * @file
    5 * Contains hook implementation for Automatic Updates Extensions.
  • 431 /**
    432 * Tests the form when an uninstallable module requires an update.
    433 */
    434 public function testUninstallableRelease(): void {
    435 $this->container->get('state')->set('testUninstallableRelease', TRUE);
    436 $this->setReleaseMetadata(__DIR__ . '/../../fixtures/release-history/semver_test.1.1.xml');
    437 $assert = $this->assertSession();
    438 $this->setProjectInstalledVersion(['semver_test' => '8.1.0']);
    439 $user = $this->createUser(['administer software updates', 'administer site configuration']);
    440 $this->drupalLogin($user);
    441 $this->drupalGet('admin/reports/updates/automatic-update-extensions');
    442 $this->checkForUpdates();
    443 $this->assertTableShowsUpdates('Semver Test', '8.1.0', '8.1.1');
    444 $this->assertUpdatesCount(1);
    445 $assert->pageTextContains('Automatic Updates Form');
    446 $assert->buttonExists('Update');
  • added 1 commit

    Compare with previous version

  • added 1 commit

    • 05961351 - removedlines to test for module updates

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading