Use of {parent:} causes glitch in {parent}{/parent} loop tag

Aperta
#5,370 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
php
Ambito
backend

Direzione di ricerca

Use the two template snippets in the issue as the entry point: both show {parents} loop output being corrupted after a single {parents:url_title} tag is used outside the loop. Reproduce against ExpressionEngine 7.5.25 with PHP 8.2 and trace how parent variables are parsed and counted in the channel entries template handler. Done means the single tag no longer alters loop counts, and each parent returns its own correct data.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description of the problem
With relationships, you can access parents with a loop, or you can access a single parent with direct tags.

But if you use both, you end up with unexpected data output errors (a bug).

How To Reproduce
Steps to reproduce the behavior:

  1. Create an entry with two or more parents in two different fields/channels
  2. Use one of the two examples below.
  3. See the wrong data

Screenshots / Videos / Template Code

TEMPLATE ONE - ONLY USING PARENTS LOOP:

{exp:channel:entries channel="chan-mag-articles" status="Open" limit="1" url_title="golden-goals" dynamic="no"}
{title}<br>
{parents field="mag_articles"}
{parents:url_title} -  {parents:title} - {parents:mag_cover}<br>
{/parents}
Text here<br>
{parents}
{parents:count} - {parents:url_title} -  {parents:title} - {parents:mag_cover}<br>
{/parents}
{/exp:channel:entries}

OUTPUT:
Golden Goals
fall-2024 - Fall 2024 - uploads/magazine/USC-Chan-Magazine-fall24.jpg
Text here
1 - courtney-shoda - Courtney Shoda Quote -
2 - fall-2024 - Fall 2024 - https://chan.usc.edu/uploads/magazine/USC-Chan-Magazine-fall24.jpg

NOTE: See how the second parent loop has correct data for each parent?

TEMPLATE TWO - USING PARENTS LOOP AND PARENTS SINGLE:

{exp:channel:entries channel="chan-mag-articles" status="Open" limit="1" url_title="golden-goals" dynamic="no"}
{title}<br>
{parents field="mag_articles"}
{parents:url_title} -  {parents:title} - {parents:mag_cover}<br>
{/parents}
Text here: {parents:url_title} - {parents:title}<br>
{parents}
{parents:count} - {parents:url_title} -  {parents:title} - {parents:mag_cover}<br>
{/parents}
{/exp:channel:entries}

OUTPUT:

Golden Goals
fall-2024 - Fall 2024 - https://chan.usc.edu/uploads/magazine/USC-Chan-Magazine-fall24.jpg
Text here: courtney-shoda - Courtney Shoda Quote
1 - courtney-shoda - Courtney Shoda Quote -
2 - courtney-shoda - Courtney Shoda Quote - https://chan.usc.edu/uploads/magazine/USC-Chan-Magazine-fall24.jpg

NOTE: See how the second parent loop has incorrect data for any single parent tag that was also used outside of the loop?

It seems like using the single parent tag outside of the loop increments that variable's count somehow.

Environment Details:

  • Version: 7.5.25
  • PHP Version 8.2
  • MySQL Version N/A
  • OS: N/A
  • Web Server: N/A

Possible Solution
No idea.

Additional context
The documentation should probably also be updated to reflect that single tag use is possible.

Lingua principale
PHP
Stelle
505
Fork
135
Merge medio
3g 7h
PR unite (30g)
7

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ExpressionEngine/ExpressionEngine

Tutte le issue di ExpressionEngine/ExpressionEngine

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.