Skip to content

PageTableArray::isValidItem() throws fatal WireException on page load in my setup #2290

Description

@er314

After upgrading PW 3.0.253 -> 3.0.269, now I have runtime exceptions in the admin upon displaying pages containing PageTable field, with the error message "Item added to ProcessWire\PageTableArray is not an allowed type".
The root cause is PageTableArray::isValidItem(), which apparently does more checks now than before.
Here is the 2 cases which are now allowed-or-denied by PageTableArray::isValidItem() :

-1- If the PageTable field is configured with a given parent page for items (therefore "All items created and managed from this field will live under the parent you select here"), then PageTableArray::isValidItem() checks that the PageTable items are a direct child of this parent page, as expected (if not -> exception)

		if($field->parent_id) { 
			// specific parent required
			if($item->parent_id != $field->parent_id) return false;
		}

-> OK, good

-2- Otherwise, PageTableArray::isValidItem() checks that the PageTable items are a direct child of the page having the PageTable field (if not -> exception)

		} else {
			// forPage required as parent
			if($item->parent_id != $this->forPage->id) return false;
		}

-> I have a problem with this new enforcement,
because I'm using a 3rd use case :

-3- My PageTable field is NOT configured with a given parent page for items, AND I manually manage the location of the PageTable items.
This used to be accepted by PW, and this used to work perfectly fine.
Now, apparently it's no more accepted.
What I do precisely is :

  • My PageTable field is configured with :
    . no contraint on the parent page for this field
    . template "order-item" is enforced for the items
  • My page tree related to this PageTable field is :
	. Page with template "order"  -> this template has the PageTable field
		. Page with template "order-items-container"  -> this is where I place the PageTable items ; actually I create each of the item Pages via API, and I place them at this location via API
			. 1-to-N Page(s) with template "order-item" -> these are the PageTable items

For my use case, this setup is better than -1- and -2-, because the PageTable items which are bound to a given main page remain "nearby & below" their main page, while also being cleanly stored in a "subfolder" dedicated to them.

Note : as soon as I remove the new check -2-, all goes well as before, end to end.

As a conclusion, I propose that check -2- is removed, in order to allow use case -3- again (thereby fixing the regression).
By doing so, Processwire will stick to checking the validity of the settings which are configured for the Pagetable field ; no more, no less.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions