Cacti / cacti

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

Improve support for Half-Hour time zones #5648

Closed bernisys closed 7 months ago

bernisys commented 8 months ago

Describe the bug

We see a lot of errors like this in the apache error logs:

Invalid date.timezone value 'Etc/GMT-5.5', we selected the timezone 'UTC' for now. in .../cacti/lib/functions.php on line 1053

To Reproduce

Steps to reproduce the behavior:

Not sure how to reproduce this properly, but we seem to have some machines which come with a time zone of "Etc/GMT-5.5" to cacti. ON processing the request, we see tons of apache error logs, because php seems not to be aware that a -5.5h time offset is indeed valid.

Expected behavior

fractions in time offsets should work, because there are half-hour offsets in the world.

Additional context

I "fixed" this for us by simply adding a "round()" around the time-offset calculation in "global.php" around line 555. I just changed it to "round(abs($hours))" instead of jsut the "abs()" part, then it doesn't throw the error any more. This is not a really clean approach though, as we cut off the half hour offset, but at least there are a lot less logs cluttering the disks.

Not sure about what the correct format here, i just wanted to stab this very quick & very dirty. But i think this gives you a good enough clue where to look into.

Cheers & keep up the good work!

bernisys commented 8 months ago

There is a similar issue listed for the Owncloud project, they seem to have solved it by mapping the fractional Etc/GMT zones to ones that actually exist in the list, with Country/City notation instead of just the offset in hours.

See: https://github.com/owncloud/core/pull/14429

TheWitness commented 8 months ago

What Cacti version @bernisys ?

TheWitness commented 8 months ago

Looks like it's not supported in any version of PHP. So, if it's not detected, I guess round is the only way to go.

bernisys commented 7 months ago

Hi Larry,

yes that's also my suspicion. I have searched a bit but did not find any useful hints, extept rounding or setting a named timezone that corresponds to the specific time offset. And our newer PHP 7.x was not supporting this either.

BTW: Our Cacti version is 1.2.17 (though this is not really relevant for this specific issue) And yes it is way old, we are planning to upgrade, but there are a few obstacles to tackle first.

On Sunday, January 28, 2024 20:25 CET, TheWitness @.> wrote:     Looks like it's not supported in any version of PHP. So, if it's not detected, I guess round is the only way to go. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.>[ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/Cacti/cacti/issues/5648#issuecomment-1913697091", "url": "https://github.com/Cacti/cacti/issues/5648#issuecomment-1913697091", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

 

TheWitness commented 7 months ago

Okay, I'm going to leave this hack in place for the moment and log something to the PHP people.

TheWitness commented 7 months ago

Logged here: https://github.com/php/php-src/issues/13428

TheWitness commented 6 months ago

@bernisys, this should be fixed in 1.2.26. I went to the PHP team and they told me that I should use a lookup table for these odd ball timezones, which I had already done post 1.2.17. Bad memory.