processwire / processwire-issues

ProcessWire issue reports.
45 stars 2 forks source link

ERROR 500 when pages, referenced by a field, are in the trash #1739

Closed tbba closed 1 year ago

tbba commented 1 year ago

Short description of the issue

When a page is in the trash that was target of a Page Reference Field (and in there a "parent" is selected/required), this can happen:

Random "ERROR 500" when not logged in, and if I am lucky (not always), I receive an error mail from Tracy about it:

_User Error: Exception: Page 4067 is not valid for wp_pluginsselector (Page 4067 does not have required parent 3691) (in /....../wire/modules/Fieldtype/FieldtypePage.module line 750) in /....../index.php:64

More comments:

Expected behavior

A page in the trash should be treated by a page reference field as "not there", so the search for an invalid required parent is not necessary, and the page is simply not found by the module.

I think this behavior is quite new. I was deleting pages before and had no ERROR 500 thereafter.

------ ATTACHMENT ----

Bildschirmfoto 54

ryancramerdesign commented 1 year ago

@tbba What action makes the error occur? Is it when you try to save the page that has the wp_plugins_selector field?

tbba commented 1 year ago

Sorry, holidays. Yes probably saving through the API (cronjob). My API code had a selector include=all (assuming that "all" does not mean trash). Since changing that to =hidden, the Fatal error is gone but I am not 100% sure that this was the problem.

I also have a warning in the backend with a table field, if a selected field source page is missing: PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in [.../site/modules/FieldtypeTable/InputfieldTable.module:205]

ryancramerdesign commented 1 year ago

@tbba The "include=all" does include trash. I actually made some other updates to FieldtypePage in 3.0.221 that I think might prevent that issue from occurring. If you are still seeing the error, please try that version and hopefully it fixes it, though let me know if not. The error you saw in InputfieldTable is just a PHP 8.x deprecation that can be ignored. That particular one is already fixed in my dev copy of Table so will be in the next version. Thanks.

matjazpotocnik commented 1 year ago

@tbba could you please check if Ryan's fix solves the issue?

matjazpotocnik commented 1 year ago

Closing on the assumption this is fixed. @tbba, please comment again if Ryan's fix doesn't work for you.