Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatrixBlocks queries include all entry revisions of related entry #4790

Closed
amphibian opened this issue Aug 21, 2019 · 2 comments
Closed

MatrixBlocks queries include all entry revisions of related entry #4790

amphibian opened this issue Aug 21, 2019 · 2 comments

Comments

@amphibian
Copy link

Description

When querying MatrixBlocks related to an entry, the results include multiple copies of each MatrixBlock, as they seem to be pulling from all revisions of the related entry. This is new in 3.2. (Previously this query worked as expected.)

Example

{% set timeslots = craft.matrixBlocks({
	fieldId:38,
	orderBy:'ownerId ASC',
	relatedTo:entry
}).all() %}

{% for slot in timeslots %}
	<p>{{ slot.owner.title }}, {{ slot.startTime|date('g:ia') }}&ndash;{{ slot.endTime|date('g:ia') }} (Entry ID: {{ slot.owner.id }}, Revision ID: {{ slot.owner.revisionId }})</p>
{% endfor %}

This results in:

Wednesday, 3:00am–5:30am (Entry ID: 298612, Revision ID: )
Wednesday, 3:00am–5:00am (Entry ID: 404131, Revision ID: 1890)
Wednesday, 3:00am–5:00am (Entry ID: 405969, Revision ID: 2574)
Wednesday, 3:00am–5:00am (Entry ID: 425192, Revision ID: 8178)
Wednesday, 3:00am–5:00am (Entry ID: 425291, Revision ID: 8191)
Wednesday, 3:00am–5:00am (Entry ID: 431435, Revision ID: 9840)
Wednesday, 3:00am–5:00am (Entry ID: 431708, Revision ID: 9910)
Wednesday, 3:00am–5:00am (Entry ID: 432003, Revision ID: 9997)
Wednesday, 3:00am–5:00am (Entry ID: 432141, Revision ID: 10005)
Wednesday, 3:00am–5:30am (Entry ID: 433066, Revision ID: 10122)

In this case there is only a single entry named "Wednesday", with an entry ID of 298612. All subsequent lines are revisions. You'' notice that I changed the current revision's end time to 5:30am - so the true entry appears first, with the "revision" copy of that entry then showing last.

Additional info

  • Craft version: 3.2.10
  • PHP version: 7.2.19
  • Database driver & version: MySQL 5.7.27
@brandonkelly
Copy link
Member

Just fixed this for the next release.

To get the fix early, change your craftcms/cms requirement in composer.json to:

"require": {
  "craftcms/cms": "dev-develop#4fc91080ec98866b3d85254fc8cd8316e4afb7fe as 3.2.10",
  "...": "..."
}

Then run composer update.

@amphibian
Copy link
Author

Thanks Brandon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants