jacobwb / hashover-next

This branch will be HashOver 2.0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comments not visible

prisae opened this issue · comments

I open a new one for this, as #276 really is about the changelog.

The issue is that I see the Hashover-Comment field. But soon as one comment is entered, it disappears. Actually, when you enter a comment and hit "Post Comment" then nothing happens. Refreshing the page then makes the whole comment section disappear.

To debug it I create a new subdomain: https://hntest.werthmuller.org

The only things on there is an index.html:

<!DOCTYPE html>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<body>
  <script type="text/javascript" src="/hashover/comments.php"></script>
</body>
</html>

and the hashover-folder. The only thing I did in the hashover folder was setting the emails, user password, and encryption key.

The comment field appears. When you commit one comment, it disappears.

Looking at the Console, as you suggested in other comments, reveals this:

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON                                     datacomments.php:281:19
    onSuccess https://hntest.werthmuller.org/hashover/comments.php:281
    onreadystatechange https://hntest.werthmuller.org/hashover/comments.php:312

So there is an error parsing the json, but I am not sure what is the issue of it.

PHP Version: 7.3.13

I think it is the same error as reported at the very end of #234 by @jorgesumle , but there is no solution presented there: #234 (comment)

It was also mentioned in #227 - but again, I did not find a solution there.

Thanks for any hints!

Hello, sorry for the delay, and please forgive my slowness to respond to your other issue as well.

Looking at the code, my first guess would be that your server doesn't have the intl extension installed. Can you check if you have this extension or not?

Here is the error that matters:

Fatal error:  Uncaught Error: Call to a member function format() on null in [...]/hashover/backend/classes/commentparser.php:270
Stack trace:
#0 [...]/hashover/backend/classes/hashover.php(331): HashOver\CommentParser->parse(Array, 1, Array)
#1 [...]/hashover/backend/comments-ajax.php(56): HashOver->parsePrimary()
#2 {main}
  thrown in [...]/hashover/backend/classes/commentparser.php on line 270

You should get an error from HashOver if the intl extension is missing, and you should definitely get an error from PHP when the code tries to instantiate the missing IntlDateFormatter object. Both of which would get caught by HashOver and displayed on your website in a more understandable and useful way. If you don't have the intl extension installed, it would be weird that this is the error that is thrown, but a certain combination of server configurations might make this kind of error possible.

For clarification, the intl extension is used to localize the comment posting dates to the configured language, for example German, so it makes sense that the code would fail after the first comment.

No problem, thanks for coming back to it. It could be. If I login via ssh and use php -m then neither intl nor json are there. However, on the phpinfo() site both are listed as enabled, so I am not sure.

I will check with my domain host, it is not my own server.

I checked with my host, and intl and json are enabled, so I am back to square one unfortunately.

This should now be fixed. The problem was your use of europe/zurich as the timezone. That is a valid timezone, but not properly capitalized, it should be Europe/Zurich. Capitalization doesn't normally matter, but it seems Intl fails if the timezone isn't properly capitalized. I have now made the code more forgiving of incorrect capitalization, so you don't need to change anything about your configuration. It should work now if you pull the latest backend/classes/settings.php file.

Let me know if the problem is fixed for you, and reopen this issue if it is not fixed.

Thanks @jacobwb, works like a charm.

Did I set europe/zurich, or was that something set from my server? (because I cannot remember having set it)

Many thanks!

As additional information. It works for PHP up to 7.3.13; it does not work (fail with the same error) for PHP 7.4.1. I set it all to 7.3.13, I assume the 7.3 series is still valid for a couple of years.

I'm glad it works now.

As to if you set it to europe/zurich yourself: Try putting this code in a file and see what you get...

<?php

echo date_default_timezone_get ();

If it shows europe/zurich then it was likely set automatically by HashOver.

You can check /etc/timezone and your php.ini file to see if it is "improperly" capitalized there as well. I would imagine that the timezone would take proper form by default, but it's possible that it does not in some distributions. This is why the code needs to be forgiving of these kinds of things.

As for PHP 7.4: It is entirely possible that HashOver doesn't work in newer versions of PHP. Personally, I am using PHP 7.2 right now. I have not had time to test newer versions.

Make sure that Intl is still enabled when you change versions. If your host uses cPanel, it is likely that different versions of PHP have different extensions enabled.

I tried your code-snippet above, and it does result in europe/zurich.

No problem regarding PHP 7.4. I stick with 7.3.x for now, and will come back to that in 1-2 years ;-)

Thanks again!