Problem/Motivation

The documentation for EntityConstraintViolationListInterface::filterByFields suggests that the result will include the given $field_names, but the opposite is actually the case. The specific part of the documentation that is wrong is:

The returned object just has violations attached to the provided fields.

Proposed resolution

Perhaps something like this would be better:

The returned object has violations attached to the provided fields removed.

Remaining tasks

Decide on wording and do!

User interface changes

None.

API changes

No change to behaviour, but fixes documentation that is the opposite. I assume this doesn't count as a BC change, as core code is using it correctly, despite the documentation actually being reversed? Either way, something should be done!

Data model changes

None.

Release notes snippet

Issue fork drupal-3098676

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

andrewbelcher created an issue. See original summary.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

danchadwick’s picture

Title: EntityConstraintViolationListInterface::filterByFields documentation is misleading » EntityConstraintViolationListInterface::filterByFields documentation is opposite of actual functionality

Confirmed.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

john.oltman made their first commit to this issue’s fork.

john.oltman’s picture

Status: Active » Needs review

I ran into this recently and it cost me a debugging session. Let's get this fixed.

I used different text vs the proposed resolution, to be consistent with the verbiage for the related filterByFieldAccess method.

smustgrave’s picture

Aren't we losing information but removing

When violations should be displayed for a sub-set of visible fields only,
* this method may be used to filter the set of visible violations first.

john.oltman’s picture

Thanks for taking a look @smustgrave. No, that text is not necessary and superfluous once the MR is applied. The new text was chosen specifically to be similar to the text for the similar filterByFieldAccess method that follows. This way both "filter" methods have similar doc, as they should.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Gotcha lets see what the committers think since it's a small MR to take a look at!

longwave’s picture

Version: 11.x-dev » 10.5.x-dev
Status: Reviewed & tested by the community » Fixed

Nice find. Wrong docs are worse than no docs, so thanks for fixing this. Backported down to 10.5.x as an docs-only bug fix.

Committed and pushed 6e6d5d4ce0e to 11.x and af48404e45c to 11.3.x and 041c6bd8c01 to 10.6.x and 3cf8bdab73a to 10.5.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • longwave committed 3cf8bdab on 10.5.x
    docs: #3098676 EntityConstraintViolationListInterface::filterByFields...

  • longwave committed 041c6bd8 on 10.6.x
    docs: #3098676 EntityConstraintViolationListInterface::filterByFields...

  • longwave committed af48404e on 11.3.x
    docs: #3098676 EntityConstraintViolationListInterface::filterByFields...

  • longwave committed 6e6d5d4c on 11.x
    docs: #3098676 EntityConstraintViolationListInterface::filterByFields...

Status: Fixed » Closed (fixed)

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