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

[Bug] Order of applied element query parameters in templates effects results of subsequent queries. #2227

Closed
monachilada opened this issue Dec 18, 2017 · 1 comment

Comments

@monachilada
Copy link
Contributor

Description

Unexpected behaviour when set several variables derived from the same field in an entry. Consider the following:

{% set materialTypes = film.materials.all() %}
{% set poster = film.materials.type('poster').one() %}
{{ dump(materialTypes|length) }}

Result is int(4)

{% set poster = film.materials.type('poster').one() %}
{% set materialTypes = film.materials.all() %}
{{ dump(materialTypes|length) }}

Result is int(3)

Where film is an entry and materials is an Entries field. The field has 4 entries attached, 3 of which are of type poster.

What I would expect is int(4) in both cases for the length of materialTypes as the Element criteria is being referenced from the film and therefore shouldn't be effected by other queries executed elsewhere. It appears to me that applying the criteria of .type('poster') is persisting to the next line.

I'm attaching a DB dump and a simplified version of the template where this is occurring.

coproduction-office_171218_171716_967vyr5h7l_v3.0.0-rc2.zip

films copy.twig.zip

Additional info

  • Craft version: 3.0.0-RC2 (Pro)
  • PHP version: 7.1.12-2+ubuntu16.04.1+deb.sury.org+2
  • Database driver & version: MySQL 5.7.20-0ubuntu0.16.04.1
  • Plugins & versions:
    • Redactor 1.0.0.1
    • CP Field Inspect 1.0.2
    • Asset Rev v6.0.0
@monachilada monachilada changed the title Order of applied element query parameters in templates effects results of subsequent queries. [Bug] Order of applied element query parameters in templates effects results of subsequent queries. Dec 18, 2017
@brandonkelly
Copy link
Member

Duplicate of #2160

@brandonkelly brandonkelly marked this as a duplicate of #2160 Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants