Plugin Author
Tim W
(@timwhitlock)
Hi.
This is very curious, because loco_include is only invoked by Loco Translate’s autoloader. To raise this error you’d have to request a class named Loco_gettext which doesn’t exist, and isn’t referenced anywhere in the plugin.
Are you able to ascertain if some other code outside the plugin is trying to make use of its files?
Thread Starter
dalibor
(@daliborpuljiz)
Apparently, “Hide Cart Functions” plugin is raising the error on Loco Translate. I wonder how is this possible. 🙂 It works if I disable either of the plugins. They used to work perfectly together.
Stack trace below:
[error] 43716#43716: *292948 FastCGI sent in stderr: "PHP message: [Loco.debug] Failed on loco_include('src/gettext.php'). !file_exists('/www/ … /public/wp-content/plugins/loco-translate/src/gettext.php'); PHP message: PHP Fatal error: Uncaught Loco_error_Exception: File not found: /www/ … /public/wp-content/plugins/loco-translate/src/gettext.php in /www/ … /public/wp-content/plugins/loco-translate/loco.php:100
0: /www/ … /public/wp-content/plugins/loco-translate/loco.php(148): loco_include('src/gettext.php')
1: [internal function]: loco_autoload('Loco_gettext')
2: /www/ … /public/wp-content/plugins/hide-cart-functions/inc/utilities-functions.php(360): class_exists('Loco_gettext')
3: /www/ … /public/wp-content/plugins/hide-cart-functions/hide-cart-functions.php(462): hwcf_translate_string('[price]')
4: /www/ … /public/wp-includes/class-wp-hook.php(343): Artiosmedia\WC_Purchase_Customization\HWCF_GLOBAl->modify_woocommerce_price('<span class="wo…')
5: /www/ … /public/wp-includes/plugin.php(205): WP_Hook->apply_filters('<span class="wo…', Array)
6: /www/ … /public/wp-content/plugins/woocommerce/includes/abstracts/abstrac" while reading response header from upstream, client: …, server: …, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/var/run/php8.5-fpm-….sock:", host: "…"
Plugin Author
Tim W
(@timwhitlock)
Thanks for this. It explains everything.
It’s happening because the other plugin is calling class_exists('Loco_gettext') which doesn’t exist. However, my autoloader is strict, so rather than class_exists returning false (as it probably should), it throws an error. It does this because the class appears to be a Loco_* class, but is not a valid one. I hadn’t anticipated other plugins to be checking for non-existent classes in my namespace.
I’ve made a note to review this behaviour so that invalid classes don’t throw fatals. However, it’s worth noting that the intention of the Hide Cart Functions plugin is to check for the presence of Loco Translate. If I fix the autoloader, their code still won’t work. They can fix that easily enough with a better check.
Thread Starter
dalibor
(@daliborpuljiz)
Righty, raising the issue onto them, then. Thanks for the reply.
Thread Starter
dalibor
(@daliborpuljiz)
Plugin Author
Tim W
(@timwhitlock)
Thanks for the update.
I still plan to fix the autoloader when I have a moment.