Prefix plugin IDs of constraints to avoid collisions

Created on 10 September 2024, 3 months ago

Description

All constraint plugins of this module use a simple ID without a module prefix. This is not the case for other plugins.

In my specific case this leads to a collision between \Drupal\field_validation\Plugin\Validation\Constraint\CurrencyConstraint and \Drupal\commerce_price\Plugin\Validation\Constraint\CurrencyConstraint

Reproduction

  1. enable commerce_cart module
  2. install and enable field_validation module
  3. create a product (with a variation)
  4. try to place that product in a cart

You will get the following error:

The website encountered an unexpected error. Try again later.

Symfony\Component\Validator\Exception\InvalidOptionsException: The options "availableCurrencies" do not exist in constraint "Drupal\field_validation\Plugin\Validation\Constraint\CurrencyConstraint". in Symfony\Component\Validator\Constraint->normalizeOptions() (line 180 of /var/www/html/vendor/symfony/validator/Constraint.php).

Symfony\Component\Validator\Constraint->__construct(Array, NULL, NULL) (Line: 47)
Symfony\Component\Validator\Constraints\Currency->__construct(Array) (Line: 31)
Drupal\Core\Validation\ConstraintFactory->createInstance('Currency', Array) (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance('Currency', Array) (Line: 86)
Drupal\Core\Validation\ConstraintManager->create('Currency', Array) (Line: 160)
Drupal\commerce_price\Plugin\Field\FieldType\PriceItem->getConstraints() (Line: 45)
...

(stack trace truncated)

🐛 Bug report
Status

Active

Version

3.0

Component

Developer experience

Created by

🇩🇪Germany tgauges

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @tgauges
  • Issue was unassigned.
  • Status changed to Needs work 3 months ago
  • 🇩🇪Germany tgauges

    I created this issue to

    • have a discussion about the problem
    • have a (temporary?) solution available
    • have a discussion about the solution

    Since my proposed solution can be seen as a breaking change, I left the merge request as a draft. Could there be other solutions?

  • Pipeline finished with Failed
    3 months ago
    Total: 546s
    #279323
  • Pipeline finished with Failed
    3 months ago
    Total: 932s
    #293037
  • Pipeline finished with Failed
    3 months ago
    Total: 441s
    #293154
  • Pipeline finished with Failed
    3 months ago
    Total: 523s
    #293175
  • Pipeline finished with Failed
    3 months ago
    Total: 499s
    #293237
  • Pipeline finished with Failed
    3 months ago
    Total: 411s
    #293251
  • Pipeline finished with Failed
    3 months ago
    Total: 418s
    #293286
  • Pipeline finished with Failed
    3 months ago
    Total: 326s
    #293318
  • Pipeline finished with Failed
    3 months ago
    Total: 548s
    #293614
  • Pipeline finished with Failed
    3 months ago
    Total: 358s
    #293625
  • Pipeline finished with Failed
    3 months ago
    Total: 394s
    #293653
  • Pipeline finished with Failed
    3 months ago
    Total: 971s
    #294660
  • Pipeline finished with Failed
    3 months ago
    Total: 408s
    #294695
  • Pipeline finished with Failed
    3 months ago
    Total: 613s
    #294726
  • Pipeline finished with Failed
    3 months ago
    Total: 417s
    #294749
  • Pipeline finished with Failed
    3 months ago
    Total: 423s
    #294752
  • Pipeline finished with Failed
    2 months ago
    Total: 481s
    #309572
  • Pipeline finished with Success
    about 1 month ago
    Total: 536s
    #344678
  • Status changed to Needs review about 1 month ago
  • 🇩🇪Germany tgauges

    Changing status to "Needs Review" to signal that input/discussion is needed.

  • 🇮🇱Israel jsacksick

    This is definitely a breaking change... Considering the problematic / conflicting constraint was added later inside the field_validation module, I think fixing it there makes more sense...

  • 🇮🇱Israel jsacksick

    Definitely a won't fix here, closing as there is an issue opened in the Field Validation queue.

  • Pipeline finished with Success
    10 days ago
    Total: 207s
    #366490
  • Pipeline finished with Skipped
    4 days ago
    #371902
Production build 0.71.5 2024