deleteInstalledVersion example

->method('set')
      ->willReturnCallback(static function D$key$value) use (&$versions) {
        $versions[$key] = $value;
      });

    $update_registry = new UpdateHookRegistry([]$this->keyValueStore);

    $this->assertSame(3000, $update_registry->getInstalledVersion('module3'));
    $update_registry->setInstalledVersion('module3', 3001);
    $this->assertSame(3001, $update_registry->getInstalledVersion('module3'));
    $this->assertSame($versions$update_registry->getAllInstalledVersions());
    $update_registry->deleteInstalledVersion('module3');
    $this->assertSame(UpdateHookRegistry::SCHEMA_UNINSTALLED, $update_registry->getInstalledVersion('module3'));
  }

}
    // updates' page without errors.     $this->drupalGet($this->updateUrl, ['external' => TRUE]);
    $this->updateRequirementsProblem();
    $this->clickLink('Continue');
    // Make sure there are no pending updates (or uncaught exceptions).     $this->assertSession()->elementTextContains('xpath', '//div[@aria-label="Status message"]', 'No pending updates.');
    // Verify that we warn the admin about this situation.     $this->assertSession()->elementTextEquals('xpath', '//div[@aria-label="Warning message"]', 'Warning message Module my_already_removed_module has an entry in the system.schema key/value storage, but is missing from your site. More information about this error.');

    // Try again with another orphaned entry, this time for a test module that     // does exist in the filesystem.     \Drupal::service('update.update_hook_registry')->deleteInstalledVersion('my_already_removed_module');
    \Drupal::service('update.update_hook_registry')->setInstalledVersion('update_test_0', 8000);
    $this->drupalGet($this->updateUrl, ['external' => TRUE]);
    $this->updateRequirementsProblem();
    $this->clickLink('Continue');
    // There should not be any pending updates.     $this->assertSession()->elementTextContains('xpath', '//div[@aria-label="Status message"]', 'No pending updates.');
    // But verify that we warn the admin about this situation.     $this->assertSession()->elementTextEquals('xpath', '//div[@aria-label="Warning message"]', 'Warning message Module update_test_0 has an entry in the system.schema key/value storage, but is not installed. More information about this error.');

    // Finally, try with both kinds of orphans and make sure we get both warnings.     \Drupal::service('update.update_hook_registry')->setInstalledVersion('my_already_removed_module', 8000);
    
// Modules can alter theme info, so refresh theme data.       // @todo ThemeHandler cannot be injected into ModuleHandler, since that       // causes a circular service dependency.       // @see https://www.drupal.org/node/2208429       \Drupal::service('theme_handler')->refreshInfo();

      \Drupal::logger('system')->info('%module module uninstalled.', ['%module' => $module]);

      /** @var \Drupal\Core\Update\UpdateHookRegistry $update_registry */
      $update_registry = \Drupal::service('update.update_hook_registry');
      $update_registry->deleteInstalledVersion($module);
    }
    // Rebuild routes after installing module. This is done here on top of     // \Drupal\Core\Routing\RouteBuilder::destruct to not run into errors on     // fastCGI which executes ::destruct() after the Module uninstallation page     // was sent already.     \Drupal::service('router.builder')->rebuild();

    // Let other modules react.     $this->moduleHandler->invokeAll('modules_uninstalled', [$module_list$sync_status]);

    // Flush all persistent caches.
Home | Imprint | This part of the site doesn't use cookies.