Cacti / cacti

Cacti ™
http://www.cacti.net
GNU General Public License v2.0
1.64k stars 405 forks source link

Translations on debian 'bookworm' systems may cause server errors #5160

Closed paulgevers closed 1 year ago

paulgevers commented 1 year ago

Describe the bug

This is a follow up of issue #5147. With the patch train provided by @netniV on top of the #5147 commits, the error message is still the same. I verified that /usr/share/php is in the include_path according to the cacti viewtech phpinfo page (although I couldn't find where it set).

[Thu Jan 12 15:27:31.996663 2023] [php:error] [pid 1005126] [client 127.0.0.1:38190] PHP Fatal error:  Uncaught Error: Class "PhpMyAdmin\\MoTranslator\\Cache\\InMemoryCache" not found in /usr/share/php/PhpMyAdmin/MoTranslator/Translator.php:115\nStack trace:\n#0 /usr/share/cacti/site/include/global_languages.php(379): PhpMyAdmin\\MoTranslator\\Translator->__construct()\n#1 /usr/share/cacti/site/include/global_languages.php(190): load_gettext_motranslator()\n#2 /usr/share/cacti/site/include/global.php(539): include_once('...')\n#3 /usr/share/cacti/site/include/auth.php(27): require_once('...')\n#4 /usr/share/cacti/site/settings.php(25): include('...')\n#5 {main}\n  thrown in /usr/share/php/PhpMyAdmin/MoTranslator/Translator.php on line 115

In Debian, the version in stable (bullseye) seems to work as expected. The php-phpmyadmin-motranslator package has changed since bullseye, the caching is new.

Although I believe this is a problem that mostly lies with Debian, I'm glad with the help offered by @netniV. I hope we can improve the code to help debugging, even if I need to fix the issue in the end in Debian.

paulgevers commented 1 year ago

With the $i18n_log set, I get the following log:

get_language_file(".mo", "/locales/LC_MESSAGES/", "/usr/share/cacti/site"): Yes - "/usr/share/cacti/site/locales/LC_MESSAGES/nl-NL.mo"
get_language_file(".js", "jquery-ui-datepicker-", "/usr/share/cacti/site/include"): No - "/usr/share/cacti/site/includejquery-ui-datepicker-nl-NL.js"
get_language_file(".js", "jquery-ui-datepicker-", "/usr/share/cacti/site/include"): No - "/usr/share/cacti/site/includejquery-ui-datepicker-nl.js"
get_language_file(".js", "jquery-ui-timepicker-", "/usr/share/cacti/site/include"): No - "/usr/share/cacti/site/includejquery-ui-timepicker-nl-NL.js"
get_language_file(".js", "jquery-ui-timepicker-", "/usr/share/cacti/site/include"): No - "/usr/share/cacti/site/includejquery-ui-timepicker-nl.js"
get_language_file(".js", "jquery-ui-colorpicker-", "/usr/share/cacti/site/include"): No - "/usr/share/cacti/site/includejquery-ui-colorpicker-nl-NL.js"
get_language_file(".js", "jquery-ui-colorpicker-", "/usr/share/cacti/site/include"): No - "/usr/share/cacti/site/includejquery-ui-colorpicker-nl.js"
get_language_file(".js", "jquery-ui-multiselect-", "/usr/share/cacti/site/include"): No - "/usr/share/cacti/site/includejquery-ui-multiselect-nl-NL.js"
get_language_file(".js", "jquery-ui-multiselect-", "/usr/share/cacti/site/include"): No - "/usr/share/cacti/site/includejquery-ui-multiselect-nl.js"
get_language_file(".js", "jquery-ui-multiselect-filter-", "/usr/share/cacti/site/include"): No - "/usr/share/cacti/site/includejquery-ui-multiselect-filter-nl-NL.js"
get_language_file(".js", "jquery-ui-multiselect-filter-", "/usr/share/cacti/site/include"): No - "/usr/share/cacti/site/includejquery-ui-multiselect-filter-nl.js"
Attempt to find the handler
require(1): Defined handler 0
get_src_language_provider(null) : 1 - No  - /usr/share/cacti/site/include/vendor/phpgettext/streams.php
get_src_language_provider(null) : 3 - No  - /usr/share/cacti/site/include/vendor/MoTranslator/Translator.php
get_src_language_provider(null) : 3 - No  - /usr/share/cacti/site/include/vendor/motranslator/Translator.php
get_src_language_provider(null) : 3 - Yes - /usr/share/cacti/site/include/vendor/motranslator/src/Translator.php
get_src_language_provider(null) : 3 - Selecting with 1 paths
require(1): Selected handler 3
require(1): Requiring /usr/share/cacti/site/include/vendor/motranslator/src/Translator.php
require(1): Requiring /usr/share/cacti/site/include/vendor/motranslator/src/StringReader.php
require(2): Final handler 3
load_language(cacti): /usr/share/cacti/site/locales/LC_MESSAGES/nl-NL.mo
load_gettext_mostranslator(cacti): /usr/share/cacti/site/locales/LC_MESSAGES/nl-NL.mo
netniV commented 1 year ago

Those logs look good. I'm going to commit the patch we have, and then if we need to adjust that, there'll be a follow-up commit.

netniV commented 1 year ago

There does seem to be a problem with the javascript includes though... need to check that.

netniV commented 1 year ago

Hi @paulgevers,

Unfortunately, I don't have those packages. My system works with the current MoTranslator.

Can you possibly zip up the /usr/share/php folder to send over those packages installed for me? I can then replace my local version and see what's going on (after backing mine up first of course!). Otherwise, I'd need a bullseye system to properly test on.

One thing you could try and do is replace the use of Translator.php and StreamReader.php with autoload.php alone. That may make things work properly.

paulgevers commented 1 year ago

https://packages.debian.org/sid/all/php-phpmyadmin-motranslator/download has links to the Debian packages that you can use to get the files (obviously in a tiny bit weird container, but alas). Let me know if that works for you.

paulgevers commented 1 year ago

And replacing

            'files' => ['Translator.php', 'StringReader.php' ],

with

            'files' => ['autoload.php' ],

seems to work.

netniV commented 1 year ago

OK, so I think we will update with that and I will test if with works with the current environment, since I have that installed.

paulgevers commented 1 year ago

By the way (maybe worth a different report) after switching the language in the settings, you need to clear your session cookie to make it active.

netniV commented 1 year ago

Yes, please create a separate issue for that. I thought that had been handled previously though.