Closed teppokoivula closed 1 year ago
@teppokoivula That indicates that the DB schema in the comments field might be old (lacking the code column) and need an update. I think it could be cleared by editing a page with a comments field and saving it? Actually, submitting a comment should have done it too. Do you still see this error if you submit another comment? Thanks.
I can confirm the described behaviour.
DB schema has column code, but entries are always NULL.
Undefined index 'code' happens because $field->schemaVersion
returns 0. See line 189.
Tested on new and existing setups on same environment as initial comment. Editing page with a comments field, editing comment field itself and submitting another comment don't help.
@androbey Thanks for confirming. I have a theory about what's going on. I think in your and @teppokoivula case, the conditions where getDatabaseSchema() would run must not have occurred. That's the method that updates the schema (and schemaVersion property). I was thinking that editing the field or saving a comment would have called that method, but it looks like it doesn't unless you change a property that affects the schema. So it looks like I'll need to manually call getDatabaseSchema() in the savePageField() method, to ensure it gets called. My test installs show a schemaVersion of 6, so I'm not seeing the error here. I'm wondering if in the admin, you go to Pages > Find, and then select your comments field in filters, that should force getDatabaseSchema() to be called. If you have another chance to test, please let me know if you you continue to see the error (or not) after doing that, and that should point us in the right direction for how best to fix it.
@ryancramerdesign I was able to briefly test the described solution. I noticed some strange behaviour, but I didn't follow it any further.
In my test install (a regularly upgraded version of ProcessWire) I have two comments fields (one "historic" which is assigned to a template and used there for some pages and one created for testing this issue, which is not assigned to a template).
Using finder (as described above) leads to some errors (e.g. stripos() expects parameter 1 to be string, array given in .../wire/core/FieldSelectorInfo.php:116
) and results in an upgraded schemaVersion property for the testing field (the one which is not assigned to a template and hence not used by any pages). The historic comment field is not updated, so the error is still present.
@teppokoivula @androbey is this still an issue? Years have passed, and there were a lot of changes in the core.
Sorry, I can't tell right now. Have stopped using the module because of this and never tried again.
Closing this now. Post more if it needs re-opening.
Short description of the issue
When I submit a comment form rendered with
$page->comments->renderForm()
, I'm seeing following notice:Setup/Environment