grav-plugin-comments icon indicating copy to clipboard operation
grav-plugin-comments copied to clipboard

Some comments are not saved

Open bastian42 opened this issue 3 years ago • 13 comments

Hi,

I have a very mysterious bug with the “comment” plugin: some comments are not saved - about 1 of 10 comments are lost.

I use

  • Grav v1.7.25,
  • Quark v2.0.4 (slightly adapted - CSS and templates) as theme
  • Comments v1.2.8
  • Form v5.1.4 on PHP 8.1.0 (I also tested PHP 7.4.25 - same problem)

In the template I have integrated the comments as follows:

{% if config.plugins.comments.enabled%} {% include 'partials / comments.html.twig' with {'page': page}%} {% endif%}

The comment fields are also displayed correctly and 9 out of 10 comments are correctly saved and the email is also sent. Only about 1 in 10 comments simply go away (not saved and no mail).

I’ve already checked logs from Grav and Apache, but there is simply nothing to be seen.

There were no unusual signs in my tests. They were structured as follows: Test date // time // number Test 30.12.21 // 19:52 // #01 …

Then some of them are missing.

Does anyone have similar experiences or a tip on how I can fix the problem.

Thank you for your support!

bastian42 avatar Dec 31 '21 15:12 bastian42

@bastian42, I have run an automated acceptance test with the Comment plugin.

  • When starting the browser and submit the Comment form 100 times: -> all 100 comments were saved.
  • When starting the browser 100 times and submitting the Comment form: -> all 100 comments were saved.

Would it be possible to create a small reproducible case I could test?

pamtbaau avatar Jan 06 '22 08:01 pamtbaau

@pamtbaau, Thank you for your help and testing.

I made a screencast of the behavior and attached it to the comment. Unfortunately, I have not discovered a reproducible process that causes the error.

https://user-images.githubusercontent.com/96482832/148440727-60ae2b0f-63d1-4776-acb7-8e80b29fb9aa.mp4

You are also welcome to try it yourself. I have a test environment and the credentials are: https://test.2278426.de User: grav_test PW: grav_test_2022

I am grateful for every idea and every hint!

bastian42 avatar Jan 06 '22 19:01 bastian42

Nothing was getting saved for me either after I copied over the comments.yaml configuration file. The "disable_on_routes" option seems to break things, but after commenting it out in the yaml it works OK.

af7567 avatar Jan 12 '22 23:01 af7567

@af7567, I don't think disable_on_routes is related to comments not being saved. When disable_on_route contains a reference to the current route, the comment form wouldn't display at all.

pamtbaau avatar Jan 13 '22 01:01 pamtbaau

@bastian42, Sorry, I've somehow missed your comment...

I've just entered a comment on page https://test.2278426.de/blog/000039_regenbogen and it doesn't show up...

Without knowing your setup, it's hard to say or test anything.

pamtbaau avatar Jan 13 '22 01:01 pamtbaau

@pamtbaau , Yes, I thought that if it was actually disabled on that path then it just wouldn't show any comments stuff at all. But I was getting the comment submission form showing, it just did nothing when clicking submit apart from reload the page. The onFormProcessed function never got called while I had the example disable_on_routes option in the config.

In my case I only wanted it active for /blog/xxxx paths, so I copied the example yaml and had this at the top

enabled: true

enable_on_routes:
  - '/blog'

disable_on_routes:
  - /blog/blog-post-to-ignore
  - /ignore-this-route
  #- '/blog/daring-fireball-link'

I thought that should be fine since none of the disabled paths match any of my paths, but this way it would show a comment form at the bottom of each blog item but clicking submit doesn't save any comments.

After changing to

enabled: true

enable_on_routes:
  - '/blog'

#disable_on_routes:
  #- /blog/blog-post-to-ignore
  #- /ignore-this-route
  #- '/blog/daring-fireball-link'

(commented out the disable_on_routes stuff) It is working.

I had a quick look through the code and couldn't see why it wold enable the comments form but not enable the onFormProcessed function.

edit: I just noticed the problem. The example comments.yaml file doesn't have quotes around the example disabled routes and that is messing up the comparisons somehow. Still strange that it shows the comments box but doesn't accept the form submission :)

af7567 avatar Jan 13 '22 14:01 af7567

I do believe you experience some unexpected behaviour, however I cannot reproduce any issue wrt. quoted/unquoted strings in enable_on_routes and disable_on_routes.

Unquoted routes used in comment.yaml show up perfectly in PHP according the debugger. Also, according To Quote or not to Quote?, quotes shouldn't be necessary considering the characters used in the routes.

pamtbaau avatar Jan 13 '22 15:01 pamtbaau

You are right, it looks like the route shouldn't need to be inside quotes. I have tested again by removing the quotes and the plugin still worked. I then put the quotes back again and it still worked. I then removed the quotes again and it stopped working. So now I have no idea what was actually causing the problem for me :) Since I don't need to disable it on any routes I can just comment out that section in the config, but I wish I knew what was going on.

af7567 avatar Jan 13 '22 18:01 af7567

@pamtbaau: Many thanks for the help.

Your comment has not been saved and I have not received an email either.

What information do you need?

Here are the

  • system.yaml from user/config
  • comments.yaml from user/config/plugin
  • comments.html.twig from user/theme/quark/templates/partials

comments.zip

bastian42 avatar Jan 13 '22 18:01 bastian42

@bastian42, I've tried your config/template files, but get errors:

  • comments.yaml => issue with "lang" (needed to uncomment "lang" field
  • system.yaml => site becomes unreachable.

I give up.

Because I cannot reproduce the issue on skeleton "Blog Site", instead of me trying to reproduce the issue you are experiencing, I would like to suggest you:

  • setup a fresh install of Grav using skeleton Blog Site
  • add plugin Comments
  • add {% include 'partials/comments.html.twig' with {'page': page} %} to /user/themes/quark/templates/item.html.twig
  • test
  • add your own template
  • test
  • add you changes user/config/plugins/comments.yaml
  • test
  • add your changes to /user/config/system.yaml
  • test
  • etc.

pamtbaau avatar Jan 14 '22 10:01 pamtbaau

@pamtbaau

OK. many thanks for the tips.

I will test them and then report.

bastian42 avatar Jan 15 '22 12:01 bastian42

My comments stopped working again without any configuration changes. I just found that if I open user/config/plugins/comments.yaml and save it again without changing anything (or just touch it) then the comments start working again. So my changes before to disable_on_routes weren't really fixing anything apart from the timestamp :)

af7567 avatar Jan 16 '22 21:01 af7567

@pamtbaau, I have done the following activities:

  • setup a fresh install of Grav using skeleton Blog Site
  • add plugin Comments
  • add {% include 'partials/comments.html.twig' with {'page': page} %} to /user/themes/quark/templates/item.html.twig
  • test

-> I have the same problem: some comments are lost!

-> I will give up with GRAV and comments... :-(

bastian42 avatar Jan 23 '22 15:01 bastian42