Skip to content
Snippets Groups Projects
Commit c66b1ce1 authored by catch's avatar catch
Browse files

Issue #2807949 by kunal.sachdev, tim.plunkett, tedbow, Dropa: update.module is...

Issue #2807949 by kunal.sachdev, tim.plunkett, tedbow, Dropa: update.module is incorrectly only responding when modules are installed

(cherry picked from commit 5f332d85)
parent f7385ac0
No related branches found
No related tags found
No related merge requests found
<?php
namespace Drupal\Tests\update\Kernel;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests the Update module storage is cleared correctly.
*
* @group update
*/
class UpdateStorageTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'update',
];
/**
* Tests the Update module storage is cleared correctly.
*/
public function testUpdateStorage() {
// Setting values in both key stores, then installing the module and
// testing if these key values are cleared.
$keyvalue_update = $this->container->get('keyvalue.expirable')->get('update');
$keyvalue_update->set('key', 'some value');
$keyvalue_update_available_release = $this->container->get('keyvalue.expirable')->get('update_available_release');
$keyvalue_update_available_release->set('key', 'some value');
$this->container->get('module_installer')->install(['help']);
$this->assertNull($keyvalue_update->get('key'));
$this->assertNull($keyvalue_update_available_release->get('key'));
// Setting new values in both key stores, then uninstalling the module and
// testing if these new key values are cleared.
$keyvalue_update->set('another_key', 'some value');
$keyvalue_update_available_release->set('another_key', 'some value');
$this->container->get('module_installer')->uninstall(['help']);
$this->assertNull($keyvalue_update->get('another_key'));
$this->assertNull($keyvalue_update_available_release->get('another_key'));
}
}
......@@ -14,7 +14,6 @@
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Site\Settings;
use Drupal\update\UpdateFetcherInterface;
......@@ -223,23 +222,21 @@ function update_themes_uninstalled($themes) {
}
/**
* Implements hook_form_FORM_ID_alter() for system_modules().
* Implements hook_modules_installed().
*
* Adds a form submission handler to the system modules form, so that if a site
* admin saves the form, we invalidate the information of available updates.
*
* @see _update_cache_clear()
* If modules are installed, we invalidate the information of available updates.
*/
function update_form_system_modules_alter(&$form, FormStateInterface $form_state) {
$form['#submit'][] = 'update_storage_clear_submit';
function update_modules_installed($modules) {
// Clear all update module data.
update_storage_clear();
}
/**
* Form submission handler for system_modules().
* Implements hook_modules_uninstalled().
*
* @see update_form_system_modules_alter()
* If modules are uninstalled, we invalidate the information of available updates.
*/
function update_storage_clear_submit($form, FormStateInterface $form_state) {
function update_modules_uninstalled($modules) {
// Clear all update module data.
update_storage_clear();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment