push-eax / pico-comments

A comments plugin for Pico CMS
MIT License
8 stars 3 forks source link

Error when using this plugin #2

Open raspbeguy opened 3 years ago

raspbeguy commented 3 years ago

Hello,

I have this error when I try to post a comment on my Pico 2.1 website using PHP 7.3 (when trying to submit the comment and just getting the page):

PHP message: PHP Warning:  Invalid argument supplied for foreach() in /var/www/lullylit/plugins/PicoComments/PicoComments.php on line 129
PHP message: PHP Warning:  usort() expects parameter 1 to be array, null given in /var/www/lullylit/plugins/PicoComments/PicoComments.php on line 153
psic commented 3 years ago

The error is below this log PHP Fatal error: Uncaught Twig\\Error\\SyntaxError: Unknown "print_comments" function. in /home/jerome/www/themes/story/single.twig:137\nStack trace:\n#0 /home/jerome/www/vendor/twig/twig/src/ExpressionParser.php(470): Twig\\ExpressionParser->getFunctionNodeClass('print_comments', 137)\n#1 /home/jerome/www/vendor/twig/twig/src/ExpressionParser.php(243): Twig\\ExpressionParsep

_self is missing in the end of the comments showing parts.

{% if comments is defined %}
    <h4>{{ comments_number }} comments</h4>
    {{ _self.print_comments(comments, false) }} --> add _self.
{% else %}
    <h3>No comments yet</h3>
{% endif %}
stoutouloutou commented 2 years ago

Hello, I got the same 2nd error : Warning: foreach() argument must be of type array|object, null given in /var/www/html/pico/plugins/PicoComments/PicoComments.php on line 129

It happens when loading the page, if I enable comments ( comment: true in the header). If I do not enable comments; the page loads, but of course I cannot add comments, as they are disabled.

I added the _self as described to remove the 1st one ([...]line 129), but it did not help for the second one...

Any ideas ?

The full error message :

Fatal error: Uncaught TypeError: usort(): Argument #1 ($array) must be of type array, null given in /var/www/html/pico/plugins/PicoComments/PicoComments.php:153 Stack trace: #0 /var/www/html/pico/plugins/PicoComments/PicoComments.php(153): usort() #1 /var/www/html/pico/plugins/PicoComments/PicoComments.php(200): PicoComments->getComments() #2 /var/www/html/pico/vendor/picocms/pico/lib/AbstractPicoPlugin.php(101): PicoComments->onPageRendering() #3 /var/www/html/pico/plugins/PicoDeprecated/PicoDeprecated.php(319): AbstractPicoPlugin->handleEvent() #4 /var/www/html/pico/plugins/PicoDeprecated/lib/AbstractPicoPluginApiCompatPlugin.php(81): PicoDeprecated->triggerEvent() #5 /var/www/html/pico/plugins/PicoDeprecated/plugins/PicoPluginApi1CompatPlugin.php(258): AbstractPicoPluginApiCompatPlugin->triggerEvent() #6 /var/www/html/pico/plugins/PicoDeprecated/lib/AbstractPicoCompatPlugin.php(74): PicoPluginApi1CompatPlugin->onPageRendering() #7 /var/www/html/pico/plugins/PicoDeprecated/lib/AbstractPicoPluginApiCompatPlugin.php(44): AbstractPicoCompatPlugin->handleEvent() #8 /var/www/html/pico/plugins/PicoDeprecated/lib/AbstractPicoPluginApiCompatPlugin.php(76): AbstractPicoPluginApiCompatPlugin->handleEvent() #9 /var/www/html/pico/plugins/PicoDeprecated/lib/AbstractPicoPluginApiCompatPlugin.php(49): AbstractPicoPluginApiCompatPlugin->triggerEvent() #10 /var/www/html/pico/plugins/PicoDeprecated/PicoDeprecated.php(134): AbstractPicoPluginApiCompatPlugin->handleEvent() #11 /var/www/html/pico/vendor/picocms/pico/lib/Pico.php(2788): PicoDeprecated->handleEvent() #12 /var/www/html/pico/vendor/picocms/pico/lib/Pico.php(512): Pico->triggerEvent() #13 /var/www/html/pico/index.php(33): Pico->run() #14 {main} thrown in /var/www/html/pico/plugins/PicoComments/PicoComments.php on line 153