Cms: relatedTo doesn't filter out disabled Matrix blocks blocks

Created on 28 Mar 2020  路  5Comments  路  Source: craftcms/cms

Description

If you are fetching related elements via a Matrix field, such as:

{% set images = craft.assets().relatedTo([
  { sourceElement: entry, field: 'articleBody.image' }
]).all() %}

鈥he results will include elements that are related via disabled Matrix blocks. Those should be ignored, though.

Steps to reproduce

  1. Create a Matrix field with a nested relational field
  2. Attach the Matrix field to a field layout
  3. Create two blocks that each contain selected relations
  4. Disable one of those blocks
  5. Run similar code in the description within a template

The result should only contain relations from the enabled block, not the disabled one.

Additional info

  • Craft version: 3.4.11
bug normal

All 5 comments

...excellent catch @brandonkelly 馃弳

Thanks for fixing this!

@narration-sd hah, credit goes to @architchandra for discovering the bug :)

emojis awarded :)

Craft 3.4.12 is out now with this fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rynpsc picture rynpsc  路  3Comments

leigeber picture leigeber  路  3Comments

mccombs picture mccombs  路  3Comments

bitboxfw picture bitboxfw  路  3Comments

angrybrad picture angrybrad  路  3Comments