Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some comments are not saved #103

Open
bastian42 opened this issue Dec 31, 2021 · 13 comments
Open

Some comments are not saved #103

bastian42 opened this issue Dec 31, 2021 · 13 comments

Comments

@bastian42
Copy link

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 // #1

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!

@pamtbaau
Copy link

pamtbaau commented Jan 6, 2022

@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?

@bastian42
Copy link
Author

@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.

test.comments.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!

@af7567
Copy link

af7567 commented Jan 12, 2022

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.

@pamtbaau
Copy link

@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
Copy link

@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.

@af7567
Copy link

af7567 commented Jan 13, 2022

@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 :)

@pamtbaau
Copy link

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.

@af7567
Copy link

af7567 commented Jan 13, 2022

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.

@bastian42
Copy link
Author

@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

@pamtbaau
Copy link

@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.

@bastian42
Copy link
Author

@pamtbaau

OK. many thanks for the tips.

I will test them and then report.

@af7567
Copy link

af7567 commented Jan 16, 2022

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 :)

@bastian42
Copy link
Author

@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... :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants