Note this is (arguably) a bug report, but I didn't want to fight that fight, so tagging as 'task'.

This was originally found in #2177799: Allow IntegerItem's to be unsigned.

Problem/Motivation

setConstraints() overrides the entire list of constraints so it may remove previously set constraints. It should only be used in tests and when the entire list of constraints has previously been fetched with getConstraints()

Proposed resolution

- Replace usages of setConstraints() with addConstraint() where appropriate.
- Add a warning to the method doc.

Remaining tasks

User interface changes

None.

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler’s picture

Title: use DataDefinition::addConstraint() instead of ::setConstraints() » Use DataDefinition::addConstraint() instead of ::setConstraints()
Issue summary: View changes
Status: Active » Needs review
Parent issue: » #2177799: Allow IntegerItem's to be unsigned
FileSize
3.12 KB

Here we go.

Status: Needs review » Needs work

The last submitted patch, 1: 2235125-1-set-vs-add-constraint.patch, failed testing.

tstoeckler’s picture

Status: Needs work » Needs review
FileSize
776 bytes
3.11 KB

Oops, too much copy and paste.

sun’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

  • Commit 83bdbd5 on 8.x by webchick:
    Issue #2235125 by tstoeckler: Use DataDefinition::addConstraint()...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.