Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293850

Add a lock around module installation

$
0
0

Problem/Motivation

Let's assume two users enable two different modules on the admin/modules page at the same time.
Then the slightly slower attempt will win, as its comes after the first one

Proposed resolution

Add a lock around module install.

Inject the lock service into the module installer service (\Drupal\Core\Extension\ModuleInstaller)
Wrap the ::install method in a lock - see the Lock API for details.
If the lock can't be acquired after waiting, throw an exception
Add a test to \Drupal\KernelTests\Core\Extension\ModuleInstallerTest to ensure the lock prevents two people from installing at the same time
Add code to \Drupal\system\Form\ModulesListForm::submitForm and \Drupal\system\Form\ModulesListConfirmForm::submitForm to catch the thrown exception and display a message to the user
Add tests to \Drupal\Tests\system\Functional\Form\ModulesListFormWebTest for these scenarios

Remaining tasks

Review + Merge

User interface changes

N/A

API changes

ModuleInstaller now has a 6th (currently optional) parameter, Lock. This is optional for BC purposes only, this is actually required and defaulted if not present.

Data model changes

N/A


Viewing all articles
Browse latest Browse all 293850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>