Prevent duplicate plugin table entries (#14120)

* Prevent duplicate plugin table entries
Some sort of race condition.
Add a unique index, this will cause the create query to fail when it tries to add a new entry for an existing plugin.

* Add index
This commit is contained in:
Tony Murray
2022-07-20 08:25:45 -05:00
committed by GitHub
parent 1a99119968
commit 9320e6cd06
3 changed files with 51 additions and 1 deletions

View File

@@ -189,7 +189,11 @@ class PluginManager
if (! $plugin) {
try {
$plugin = Plugin::create([
// plugin should not exist, but check for safety
$plugin = Plugin::firstOrCreate([
'version' => 2,
'plugin_name' => $name,
], [
'plugin_name' => $name,
'plugin_active' => $name !== 'ExamplePlugin',
'version' => 2,