statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
3.99k stars 525 forks source link

Related entries not loading entries #8766

Closed FrankPeters closed 1 year ago

FrankPeters commented 1 year ago

Bug description

Since the Statamic 3.2->3.3->3.4->4.0 upgrade (not sure when it broke) a related entries tag seems broken. I am aware of the breaking change, but even if I simply try to load the items it doesn't work. Some context:

My blueprint:

  -
    handle: job_box_items
    field:
      type: entries
      max_items: 3
      sort: 'date:desc|title:asc'
      label: '[{{ date format="d M Y" }}] {{ title }}'
      mode: select
      display: Jobs
      collections:
        - jobs
      localizable: false
      instructions_position: above
      listable: hidden
      visibility: visible
      create: false
      hide_display: false

My markdown:

        job_box_items:
          - 849eea9f-a83e-4d80-9c10-a6c4cbb17d03
          - 3b1bb605-71fb-40ec-a488-5c6f626bbd66
          - 6759e1a4-4279-4630-b269-d4b1296b742b

My antlers:

                    {{ job_box_items }}
                        {{ partial:bards/partials/job-box-item }}
                    {{ /job_box_items }}

The partial loads a small component and references things like {{ url }} and {{ title }}.

It renders, but instead of showing three items, it shows one and the URL and the Title are from the page that contains this bard set and not one of the job openings.

I have tried changing the blueprint and re-selecting the items but to no avail (the blueprint is actually the updated version, the old V3.2 one still used 'tags').

How to reproduce

See bug description.

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 9.52.15
PHP Version: 8.0.30
Composer Version: 2.6.3
Environment: local
Debug Mode: ENABLED
URL: localhost
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: daily
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 5
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.22.0 PRO

Statamic Addons
aryehraber/statamic-captcha: 1.10.0
jacksleight/statamic-bard-texstyle: 3.1.3
private/repo: dev-develop
statamic/seo-pro: 5.2.2
xndbogdan/statamic-bard-text-color: 4.0.0

Installation

Other (please explain)

Antlers Parser

runtime (new)

Additional details

No response

FrankPeters commented 1 year ago

I've tried dumping the variable job_box_items and notice that in the EntryQueryBuilder the $collections array is null. I am not sure if this is supposed to be the case as it's supposed to be linked to the jobs collection.

jasonvarga commented 1 year ago

in the EntryQueryBuilder the $collections array is null

That's fine, because it's querying by the IDs.

It renders, but instead of showing three items, it shows one and the URL and the Title are from the page that contains this bard set and not one of the job openings.

When this happens it usually means there's no results.

Are those 3 selected entries drafts?

FrankPeters commented 1 year ago

I think there was some confusion between the different published states. I was looking at the published boolean that sometimes disappears, but that's because the default status is published. Thanks for the directions.