I use JComments and had the same issue when I upgraded to PHP 7.2 and was able to quickly solve the errors.borja wrote: ↑Tue Jun 19, 2018 1:31 pmHello
I use jcomments and kcaptcha on my web. Today it stopped working the captcha. As far as I have read:
I have a problem because the Kcaptch class is deprecated and there were some problems with the captcha.
I change the php twice and it started to work again. the first change was to change the version of php from 7.0.30 to 5.6.36. My web doesn´t work. I went back from 5.6.36 o 7.0.30 and the captcha started to work properly.
what can be wrong?
JComments is not busted or outdated, the developer used the constructor naming method to serve backward compatibility, many devs did so, but now PHP is strict so it is deprecated.
From php.net
The Fix"For backwards compatibility with PHP 3 and 4, if PHP cannot find a __construct() function for a given class, it will search for the old-style constructor function, by the name of the class. Effectively, it means that the only case that would have compatibility issues is if the class had a method named __construct() which was used for different semantics."
Edit the files that causes the warning and change the function name to the php core keyword __construct.
The files I edited were primarily in the frontend directory components/com_jcomments
- libraries/kcaptcha/kcaptcha.php Change function KCAPTCHA() to function __construct()
- classes/acl.php Change function JCommentsACL() to the same construct as above
- helpers/pagination.php Change function JCommentsPagination()
- tpl/default/tpl_form.php find if ( (count($customBBCodes)) ) and change to if ($customBBCodes). This is also a new strict rule. When count() is empty, php 7x will complain. The condition is just to determine if bbcodes is enabled
Now JComments will be functioning fine. No need to worry about an update overwriting the core changes. It's quite likely that the developer is aware of the deprecated methods and any release will include the changes you made.
See more about php constructors at http://php.net/manual/en/language.oop5.decon.php