Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language support under Debian Buster does not work as expected #2924

Closed
Benhool77 opened this issue Sep 3, 2019 · 23 comments
Closed

Language support under Debian Buster does not work as expected #2924

Benhool77 opened this issue Sep 3, 2019 · 23 comments
Labels
3rd Party Bug 3rd party bug resolved A fixed issue
Milestone

Comments

@Benhool77
Copy link

Describe the bug

on a fresh system with Debian testing bullseye netinstall, cacti seems to be broken (install via apt... with apache)

/var/log/apache2/error.log
PHP Warning: require(/usr/share/cacti/site/include/vendor/phpgettext/streams.php): failed to open stream: No such file or directory in /usr/share/cacti/site/include/global_languages.php on line 157
PHP Fatal error: require(): Failed opening required '/usr/share/cacti/site/include/vendor/phpgettext/streams.php' (include_path='.:/usr/share/php') in /usr/share/cacti/site/include/global_languages.php on line 157

no streams.php found on this system:
root@bulls-test:~ find / -name 'streams.php'
root@bulls-test:~ (no result)

To Reproduce

Install debian testing Bullseye
install cacti via "apt install cacti"
choose apache as your web-server
connect to your cacti server http://yourcactiserver/cacti (it don't works...)
display /var/log/apache2/error.log

seems to be linked with this issue #2508
since phpgettext has been disabled

link in cacti forum
https://forums.cacti.net/viewtopic.php?f=2&t=60110

thanks

@interduo
Copy link
Contributor

interduo commented Sep 4, 2019

Don't use debian package. Use git. You would have more fresh code.

For You issue try:
apt install php-gettext

@Benhool77
Copy link
Author

@interduo: php-gettext has been retired from debian bullseye's repository

@netniV
Copy link
Member

netniV commented Sep 4, 2019

Yes, @Benhool77 is correct it was retired and I agreed with it as I'd been informed we were not reliant upon it for some time. Unfortunately, that appears to be incorrect as my testing is showing it actively being used so we need to review this more thoroughly to see what we do next.

@cigamit
Copy link
Member

cigamit commented Sep 5, 2019

So, when Paul mentioned that they are removing phpgettext, I was certain it was the php module, and not the emulation layer that we use in the case that the php maintained module php-gettext was not available.

I would like to ask @paulgevers, what Debian plans to use as a replacement for gettext in PHP for web application that wish to work with different languages. Seems almost like cutting off one arm due to the face that you cant stand to look at the wart that formed there.

@paulgevers
Copy link
Contributor

@cigamit, cacti was together with one other package the only web application that was using phpgettext.

As mentioned in issue #2508, there is a maintained fork: https://github.com/phpmyadmin/motranslator/, which is also available in Debian (unstable).

@netniV
Copy link
Member

netniV commented Sep 5, 2019

I think the confusion with php-gettext is that there is a php module as well as a php code library of the same name and that Debian uses the original php-gettext as an alias to php-php-gettext (which is the code version not the module).

Since it is the emulator (php-php-getttext) that's being removed, I took a look at the above motranslator and it would appear to be relatively simple to drop in though I haven't checked the licensing yet.

As long as we have all the pre-requisites it needs in the vendor folder (as Cacti doesn't utilise composer itself) for those who aren't using the debian package. @mortenstevens will likely want to update his package requirements to mirror this too once we have it in place.

@netniV netniV changed the title Debian testing Bullseye - apt install - PHP Fatal error phpgettext Language support under Debian Buster does not work as expected Sep 12, 2019
@netniV
Copy link
Member

netniV commented Sep 12, 2019

@paulgevers / @mortenstevens,

I took a look at MoTranslator though that has some dependancies and requirements that we can't really support right now as the minimum PHP version must be 7.1. I have had a look and also found https://github.com/oscarotero/Gettext which appears to be another library which I have managed to get working and supports PHP 5.4+.

Would that one be OK to use or do we need to keep looking? Failing that, we are going to have to raise the minimum PHP level which I don't mind doing for 1.3 when it eventually comes out but I would hate to enforce on a patch revision of 1.2.x

@paulgevers
Copy link
Contributor

paulgevers commented Sep 14, 2019 via email

@netniV
Copy link
Member

netniV commented Sep 14, 2019

At the moment, there will be no foreign language support without one or the other. Fine for the English speaking world but to suddenly lose translation on an upgrade would be bad IMHO.

Do you need to maintain another packager if it's part of our sources and doesn't currently exist?

@paulgevers
Copy link
Contributor

paulgevers commented Sep 15, 2019 via email

@netniV
Copy link
Member

netniV commented Sep 15, 2019

You help us out by not having us have to go through the Debian hoops ourselves so a small tweak from outside isn’t too much to ask for to keep it going on their environments.

What I can do is make the code able to use MoTranslator but that will require two things, a minimum PHP level of 7.1 and a setting in either the database or configuration file. I’m not sure what the minimum PHP version is on your base systems so there may be a conflict there.

If you look at the proposed changes so far for the i18n branch it wouldn’t take much to adjust for MoTranslator but as that also requires Symfony etc we wouldn’t package with it because it would just bloat our sizes up even more.

If you are OK with that, I’ll look into it later today.

@netniV
Copy link
Member

netniV commented Sep 15, 2019

Oh just read about the PHP version so that should be fine

@mortenstevens
Copy link
Contributor

From a technical point of view, I would also recommend increasing the minimum PHP version to 7.1. But this will affect only cacti 1.3?

@netniV
Copy link
Member

netniV commented Sep 15, 2019

We haven’t actually made that decision yet but based upon recent events I am tempted to ask about raising the bar. However we have had a few reports of issues recently that where from people still running PHP 5.4

@cigamit
Copy link
Member

cigamit commented Sep 15, 2019

If we can get RedHat to make PHP 7.x available in RHEL7, then I'm good with this approach.

From the point of view of the i18n library, I would not be against taking over management of the package and embedding directly into Cacti. We would need to resolve the CVE associated with the use of the eval() command of course. I suspect that there is not much to change outside of that over time unless PHP starts deprecating or changing the behavior of some of it's commands, which of course, we have seen in the past..

@paulgevers, would that be acceptable to Debian. We would move the files out of the vendor directory and maintain the original authors copyright.

@netniV
Copy link
Member

netniV commented Sep 15, 2019

I've pushed a change to allow MoTranslator as a translation provider to the i18n branch. To use this, set the l10n_language_handler to 3 (MoTranslator) in either config.php's config array or the settings table.

@cigamit cigamit added the 3rd Party Bug 3rd party bug label Sep 15, 2019
@paulgevers
Copy link
Contributor

@netniV I appreciate the i18n branch. I have several questions and remarks.

  1. there is a typo in the auto-detection: mottanslator instead of motranslator.
  2. reading the comments in include/global_languages.php I get the impression that i18n support is off by default, but on my system it always tries it. Is the (! && ) in php doing (!( && )) or ((!) && ())? In the latter case I think there is a tiny mistake on line 40.
  3. I was not able to force the handler, whatever I tried it found the handler via the auto-detection. Is it supposed to be added to the settings table and/or the configuration file and should it call the number? It's not really needed to define, as auto-detection works properly, but I was just wondering.
  4. When I change the language for a user the first time, it's switched to that language immediately, however, a subsequent switch keeps the old language until I clear the cookie. Do you want a separate bug report for that?

@netniV netniV closed this as completed Sep 19, 2019
@netniV netniV reopened this Sep 19, 2019
@netniV
Copy link
Member

netniV commented Sep 19, 2019

Firstly, are you making sure to use l10n (that's LIMA TEN NOVEMBER) since it's the localization handler we are trying to find, not i18n (INDIGO 18 NOVEMBER) which is the internationalisation code ? (I followed the existing coding conventions).

That aside, on your list

  1. there is a typo in the auto-detection: mottanslator instead of motranslator.

Fixed

  1. reading the comments in include/global_languages.php I get the impression that i18n support is off by default, but on my system it always tries it. Is the (! && ) in php doing (!( && )) or ((!) && ())? In the latter case I think there is a tiny mistake on line 40.

If you use read_config_option() with no value set, it could return false/empty, where as if you set the option off read_config_option() will return 0.

So, to distinguish, the code checks if read_config_option() is not true (0/false being false, 1+ being true) and then also checks if the option isn't blank (since 0 wouldn't be blank)

  1. I was not able to force the handler, whatever I tried it found the handler via the auto-detection. Is it supposed to be added to the settings table and/or the configuration file and should it call the number? It's not really needed to define, as auto-detection works properly, but I was just wondering.

The code is designed such that you can set the setting in the following priority order:

  1. Settings table (Line 169)
  2. Configuration file (line 174)
  3. Auto detection (Line 178)
  4. No translation (assumed by failing to get a handler)

Again, double check that you are using the correct prefix as mentioned above 👍

  1. When I change the language for a user the first time, it's switched to that language immediately, however, a subsequent switch keeps the old language until I clear the cookie. Do you want a separate bug report for that?i18n support is on by default.

That does sound like a bug. However, I have never noticed an issue changing my language as long as it's done via the user profile. If you change the global language, this isn't automatically populated down to users because we don't overwrite the settings already stored for them.

I had previous suggested that we only store a setting if overridden thus many settings would be kept to the system defaults and potentially even allow the admin to define the user settings that can be overridden but that's a future project.


So, if you want to check out what is occurring above, the simplest thing is to create /share/ with full write permissions to your web servers user account (more than likely apache).

@mortenstevens
Copy link
Contributor

If we can get RedHat to make PHP 7.x available in RHEL7, then I'm good with this approach.

PHP 7.x is available for RHEL7 via RH Software Collections (SCL). But we can't require SCL packages for Fedora-EPEL.

Since RHEL7 is over 5 years old, I think it's time to switch to RHEL8/CentOS 8. So my plan is to ship cacti 1.3.x only for RHEL8 and we can continue to support RHEL7 with cacti 1.2.x security updates only?

@netniV
Copy link
Member

netniV commented Sep 19, 2019

1.2.x for RHEL 7 and 1.3.x for RHEL 8 ? Sounds good though 1.3 may be a while yet. We've barely started on it.

@cigamit
Copy link
Member

cigamit commented Sep 25, 2019

I think we can close this since it's merged into the 1.2.7 now.

@cigamit cigamit closed this as completed Sep 25, 2019
@cigamit cigamit added this to the v1.2.7 milestone Sep 25, 2019
@cigamit cigamit added the resolved A fixed issue label Sep 25, 2019
@netniV
Copy link
Member

netniV commented Oct 3, 2019

@paulgevers has this now made it's way to debian?

@paulgevers
Copy link
Contributor

@netniV yes, I pulled the pieces from the branch before it was merged. It's part of 1.2.6+ds1-3, which is in testing now.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3rd Party Bug 3rd party bug resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

6 participants