Addpixel / KirbyComments

[Kirby 2] File-based comments stored as subpages for the Kirby CMS.
MIT License
68 stars 5 forks source link

max-character-count prevents old comments from showing; breaks comment form #9

Closed samnabi closed 7 years ago

samnabi commented 7 years ago

If you have an existing comment whose text field is 900 characters long, it will be fine because the default max-character-count is 1000.

However, if you decide to change the max-character-count in the future to 500, the existing comment will not show up. It gets caught by the Comment constructor and returns an error.

Now, this is a problem for writing new comments too. Since the existing comment doesn't make it through to the $comments array in the template, the numbering is off for any new comments. The submission form counts the wrong number of existing comments, and therefore tries to submit a comment with an ID that already exists. The form will silently fail, and never show the preview.

I haven't tested this extensively, but I think the main problem here is with the Comment constructor function. The validation code shouldn't apply retroactively to existing comments.

florianpircher commented 7 years ago

Thank you for finding this bug! By making the constructor more save I made it incompatible with possible feature settings. While some options can not be changed once the plugin is in use, I agree that this should not be some of them.