Skip to content

Unusual behaviour when Page Reference field contains trashed page #620

Open
@Toutouwai

Description

@Toutouwai

Short description of the issue

Page Reference fields behave in an unusual way when they contain a page that has been trashed. Take the following scenario...

In my home template I have two Page Reference fields, "test_page_single" and "test_page_multiple". In each of these fields I add the same "To trash" page (and only that page).

2018-06-13_194806

I then trash the "To trash" page. Now when I edit the Home page these fields appear to be empty.

2018-06-13_194845

But in the fields' tables in the database the value is retained. And I can save the Home page with these fields in their apparently empty state but still the trashed page is retained. This makes it impossible to remove the trashed page as a value and save these fields in a genuinely empty state. It is also potentially misleading as there is no way to tell the difference between an empty field and one that actually contains a trashed page.

When I get the value of these fields via the API they behave as if they are empty.

2018-06-13_195444

However, I cannot match the Home page in a selector that you would expect to work if these fields were empty.

2018-06-13_200237

I find this counter-intuitive. And if you are wanting to find both pages where the field is empty and appears to be empty due to containing a trashed page, what selector can you use for this?

So it's difficult to identify pages that are in this situation both via the admin interface and via the API, which can lead to a lot of head-scratching and time spent trying to work out what's going on.

I'm not sure what a good solution would be. It would be desirable if Page Reference fields containing trashed pages responded the same way as when they contain a page that is permanently deleted, but on the other hand I can imagine scenarios where a user trashes a page in error and you want to later restore it and retain the references to it. Does anyone have any ideas on how we could have the best of both worlds?

Setup/Environment

  • ProcessWire version: 3.0.105

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions