Fix pip name uniqueness validation when editing PIP entry via GUI
authorMatthias Schmidt <gravatronics@live.com>
Sat, 13 Oct 2018 12:04:01 +0000 (14:04 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 13 Oct 2018 12:04:01 +0000 (14:04 +0200)
See #2545

wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php

index d1ccb33cc8d48cb8d485959223d22aead61dfb18..2f83206c957e8aeeb033d51979d00b659de7555a 100644 (file)
@@ -120,16 +120,21 @@ class PIPPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                                        }
                                }))
                                ->addValidator(new FormFieldValidator('uniqueness', function(TextFormField $formField) {
-                                       $pipList = new PackageInstallationPluginList();
-                                       $pipList->getConditionBuilder()->add('pluginName = ?', [$formField->getValue()]);
-                                       
-                                       if ($pipList->countObjects()) {
-                                               $formField->addValidationError(
-                                                       new FormFieldValidationError(
-                                                               'format',
-                                                               'wcf.acp.pip.pip.pluginName.error.notUnique'
-                                                       )
-                                               );
+                                       if (
+                                               $formField->getDocument()->getFormMode() === IFormDocument::FORM_MODE_CREATE ||
+                                               $this->editedEntry->getAttribute('name') !== $formField->getValue()
+                                       ) {
+                                               $pipList = new PackageInstallationPluginList();
+                                               $pipList->getConditionBuilder()->add('pluginName = ?', [$formField->getValue()]);
+                                               
+                                               if ($pipList->countObjects()) {
+                                                       $formField->addValidationError(
+                                                               new FormFieldValidationError(
+                                                                       'format',
+                                                                       'wcf.acp.pip.pip.pluginName.error.notUnique'
+                                                               )
+                                                       );
+                                               }
                                        }
                                })),