Conversation
287dd16 to
63110a8
Compare
| } | ||
|
|
||
|
|
||
| public function prepareInputForUpdate($input) |
There was a problem hiding this comment.
Should itemtypes also be validated/re-encoded in prepareInputForUpdate()? It's a real DB column update() will persist, even though the edit UI doesn't expose it.
There was a problem hiding this comment.
The GenericObject migration (inc/container.class.php:208–220) renames the tables itself, then calls update() with itemtypes provided as a JSON string. This is the same case as name, which is intentionally left unchanged for the same reason (see the comment: “see migration callers”).
Consequence
Removing itemtypes in prepareInputForUpdate() would break this migration.
My proposal
-
Extract the regex validation logic from
prepareInputForAdd()into a small private method that can be reused. -
In
prepareInputForUpdate(), ifitemtypesis present, decode it usingPluginFieldsToolbox::decodeJSONItemtypes(). Reject the update (return falsewith an error message) if any entry is invalid; otherwise, re-encode it as JSON. This ensures that the migration continues to work. -
In
front/container.form.php, removeitemtypes(as well astypeandsubtype) from$_POSTbefore callingupdate(). Structural changes should remain restricted to migrations, which is consistent with the behavior exposed by the UI.
Checklist before requesting a review
Please delete options that are not relevant.
Description
Screenshots (if appropriate):