- Issue created by @kala4ek
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 3:40pm 27 June 2023 - last update
over 1 year ago Patch Failed to Apply - last update
over 1 year ago 5 pass - last update
over 1 year ago 5 pass - 🇷🇺Russia kala4ek 🇷🇺 Novosibirsk
Also need to override default ValidReference constraint.
- last update
about 1 year ago 5 pass - 🇷🇴Romania amateescu
I've been thinking about this problem for a while, and finally decided to go in a (somewhat radical) different direction: Trash needs to prevent entity_load from returning trashed entities completely.
This was based on observations from custom code on various sites, and the problem that stood out the most was that there are cases where entity-derived data is displayed without going through access checks, for example directly outputting the result of
count($entity->get('some_reference_field')->referencedEntities())
, which internally does an entity_load_multiple, but doesn't run any access checks. This specific example could've been solved by overriding core's field item list class for ER fields, but then contrib/custom code that also override it wouldn't benefit from our changes.This decision is also in line with the recent fix from 🐛 Trash breaks revision-based views and relation queries Fixed , which made all views (using either the
data
or therevision data
as the base table) stop returning trashed entities by default. - Status changed to Fixed
about 1 year ago 8:12pm 31 October 2023 -
amateescu →
committed dc4093ac on 3.x
Issue #3370639 followup: Prevent trashed entities from being returned by...
-
amateescu →
committed dc4093ac on 3.x
- 🇷🇴Romania amateescu
Now that we don't return anything on entity_load, we need different approaches for trash routes (restore, purge) and for viewing trashed entities.
Committed the followup patch attached to 3.x.
Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
about 1 year ago 3:05pm 15 November 2023 - 🇷🇺Russia kala4ek 🇷🇺 Novosibirsk
Hm, but how it will works with entity edit forms? Looks like now trashed entites wouldn't displayed in referency fields anymore and after submitting the form, reference would gone. That means if the admin will restore the trashed node, it wouldn't appears at the place where it was before...
- 🇷🇴Romania amateescu
@kala4ek, that's right, the new behavior is closer to the entity being actually deleted, which matches the scenario you described. Fixing the problem within
\Drupal\Core\Field\EntityReferenceFieldItemList::referencedEntities()
would have had the same outcome.