qtranslate / qtranslate-xt

qTranslate-XT (eXTended) - reviving qTranslate-X multilingual plugin for WordPress. A new community-driven plugin soon. Built-in modules for WooCommerce, ACF, slugs and others.
GNU General Public License v2.0
546 stars 103 forks source link

[date_time.php] Functions taking comment arguments have wrong type #1335

Closed justinbb closed 1 year ago

justinbb commented 1 year ago

Describe the bug Because of a type error in the declaration of qtranxf_dateFromCommentForCurrentLanguage() and qtranxf_timeFromCommentForCurrentLanguage(), display of any article with comments crashes.

Debug info PHP 7 error message: PHP Fatal error: Uncaught TypeError: Argument 5 passed to qtranxf_timeFromCommentForCurrentLanguage() must be of the type string or null, object given, called in /public_html/wp-includes/class-wp-hook.php on line 303 and defined in /public_html/wp-content/plugins/qtranslate-xt/src/date_time.php:433

PHP 8 error message: PHP Fatal error: Uncaught TypeError: qtranxf_timeFromCommentForCurrentLanguage(): Argument #5 ($comment) must be of type ?string, WP_Comment given, called in /public_html/wp-includes/class-wp-hook.php on line 303 and defined in /public_html/wp-content/plugins/qtranslate-xt/src/date_time.php:433

Additional context New problem in qtranslate-xt 3.15.0. The argument has always been a WP_Comment, but explicit typing was not previously present.

herrvigg commented 1 year ago

Good you also caught this. The comment was also wrong for the equivalent date function. These are now fixed in the master branch.

I found many other problems, not only due to the new PHP type signatures but also with the legacy callbacks using wrong parameters. More fixes to come.

herrvigg commented 1 year ago

Fix released in 3.15.1.