PHP warnings

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Moderators, Developers

Post Reply
Author
Message
Helmut Schneider
Cacti User
Posts: 135
Joined: Mon Feb 05, 2007 3:57 am
Location: Munich, Germany

PHP warnings

#1 Post by Helmut Schneider » Mon Jan 15, 2018 12:04 pm

Hello,

running Cacti 1.1.30 on FreeBSD with PHP7 I get some warnings clicking on graph details

Warning: numfmt_set_attribute() expects parameter 1 to be NumberFormatter, null given in /var/www/cacti/include/global_languages.php on line 579
Warning: numfmt_format() expects parameter 1 to be NumberFormatter, null given in /var/www/cacti/include/global_languages.php on line 581

Anything to worry?

Thanks!

netniV
Cacti Guru User
Posts: 2691
Joined: Sun Aug 27, 2017 12:05 am

Re: PHP warnings

#2 Post by netniV » Mon Jan 15, 2018 1:41 pm

This would suggest that the numfmt_create() function returned a null value since that is the value used as paramter 1 on the lines in question. Do you know what your $cacti_locale and $cacti_country are currently set to?

netniV
Cacti Guru User
Posts: 2691
Joined: Sun Aug 27, 2017 12:05 am

Re: PHP warnings

#3 Post by netniV » Mon Jan 15, 2018 1:52 pm

Looking at the code, it should check that the $fmt is FALSE and if so, try the older methods of working numbers out.

So I filed a bug:
https://github.com/Cacti/cacti/issues/1206

netniV
Cacti Guru User
Posts: 2691
Joined: Sun Aug 27, 2017 12:05 am

Re: PHP warnings

#4 Post by netniV » Mon Jan 15, 2018 3:13 pm

This will be corrected in the v1.0.31 release. Note, it doesn't fix the actual problem, but if you set your logging level to HIGH it will show an entry stating that it had to revert the number format back to the original methods. It will show the key used in quotes so if you could get that once you have a chance to update, that may help identify the issue.

Helmut Schneider
Cacti User
Posts: 135
Joined: Mon Feb 05, 2007 3:57 am
Location: Munich, Germany

Re: PHP warnings

#5 Post by Helmut Schneider » Tue Jan 16, 2018 3:49 am

[quote="netniV"]This would suggest that the numfmt_create() function returned a null value since that is the value used as paramter 1 on the lines in question. Do you know what your $cacti_locale and $cacti_country are currently set to?[/quote]

/* default localization of Cacti */
$cacti_locale = 'en';
$cacti_country = 'us';

netniV
Cacti Guru User
Posts: 2691
Joined: Sun Aug 27, 2017 12:05 am

Re: PHP warnings

#6 Post by netniV » Tue Jan 16, 2018 6:04 am

Hmm, that is the default values, but that gets overridden by your Browser Settings, Cacti User settings, Cacti System Settings and finally default settings. If it does end up being 'en' and 'us' that should result in a number format of en-US which is valid according to the example at http://php.net/manual/en/class.numberformatter.php

Code: Select all

$adminFormatter = new \NumberFormatter("en-US", \NumberFormatter::CURRENCY); 
I'll see if I can throw a test file together to proof the format.

netniV
Cacti Guru User
Posts: 2691
Joined: Sun Aug 27, 2017 12:05 am

Re: PHP warnings

#7 Post by netniV » Sun Jan 21, 2018 5:37 pm

Add the attached file to your base cacti folder and then change the .txt to .php. Ensure you are logged in, then browse to <cacti site>/test_lang.php

This should give you some debug information about the language settings being used and the number formatter that was being picked if any.

The first textarea that appears will be the languages that cacti knows about. You can ignore this, but if you copy and paste the rest of the contents, I can see whether that has any bearing on the issue you've had.
Attachments
test_lang.txt
Rename to .php
(5.84 KiB) Downloaded 82 times

YATV
Posts: 4
Joined: Wed Oct 14, 2015 8:20 pm

Re: PHP warnings

#8 Post by YATV » Fri Apr 19, 2019 3:26 am

array (
'sq-AL' =>
array (
'language' => 'Albanian',
'direction' => 'ltr',
'country' => 'al',
'filename' => 'albanian_albania',
),
'ar-SA' =>
array (
'language' => 'Arabic',
'direction' => 'rtl',
'country' => 'sa',
'filename' => 'arabic_saudi_arabia',
),
'hy-AM' =>
array (
'language' => 'Armenian',
'direction' => 'ltr',
'country' => 'am',
'filename' => 'armenian_armenia',
),
'be-BY' =>
array (
'language' => 'Belarusian',
'direction' => 'ltr',
'country' => 'by',
'filename' => 'belarusian_belarus',
),
'bg-BG' =>
array (
'language' => 'Bulgarian',
'direction' => 'ltr',
'country' => 'bg',
'filename' => 'bulgarian_bulgaria',
),
'zh-CN' =>
array (
'language' => 'Chinese (China)',
'direction' => 'ltr',
'country' => 'cn',
'filename' => 'chinese_china_simplified',
),
'zh-HK' =>
array (
'language' => 'Chinese (Hong Kong)',
'direction' => 'ltr',
'country' => 'hk',
'filename' => 'chinese_hong_kong',
),
'zh-SG' =>
array (
'language' => 'Chinese (Singapore)',
'direction' => 'ltr',
'country' => 'sg',
'filename' => 'chinese_singapore',
),
'zh-TW' =>
array (
'language' => 'Chinese (Taiwan)',
'direction' => 'ltr',
'country' => 'tw',
'filename' => 'chinese_taiwan',
),
'hr-HR' =>
array (
'language' => 'Croatian',
'direction' => 'ltr',
'country' => 'hr',
'filename' => 'croatian_croatia',
),
'cs-GZ' =>
array (
'language' => 'Czech',
'direction' => 'ltr',
'country' => 'cz',
'filename' => 'czech_czech_republic',
),
'da-DK' =>
array (
'language' => 'Danish',
'direction' => 'ltr',
'country' => 'dk',
'filename' => 'danish_denmark',
),
'nl-NL' =>
array (
'language' => 'Dutch',
'direction' => 'ltr',
'country' => 'nl',
'filename' => 'dutch_netherlands',
),
'en-US' =>
array (
'language' => 'English',
'direction' => 'ltr',
'country' => 'us',
'filename' => 'english_usa',
),
'en-GB' =>
array (
'language' => 'English (Britain)',
'direction' => 'ltr',
'country' => 'gb',
'filename' => 'english_gb',
),
'et-EE' =>
array (
'language' => 'Estonian',
'direction' => 'ltr',
'country' => 'ee',
'filename' => 'estonian_estonia',
),
'fi-FI' =>
array (
'language' => 'Finnish',
'direction' => 'ltr',
'country' => 'fi',
'filename' => 'finnish_finland',
),
'fr-FR' =>
array (
'language' => 'French',
'direction' => 'ltr',
'country' => 'fr',
'filename' => 'french_france',
),
'de-DE' =>
array (
'language' => 'German',
'direction' => 'ltr',
'country' => 'de',
'filename' => 'german_germany',
),
'el-GR' =>
array (
'language' => 'Greek',
'direction' => 'ltr',
'country' => 'gr',
'filename' => 'greek_greece',
),
'he-IL' =>
array (
'language' => 'Hebrew',
'direction' => 'rtl',
'country' => 'il',
'filename' => 'hebrew_israel',
),
'hi-IN' =>
array (
'language' => 'Hindi',
'direction' => 'ltr',
'country' => 'in',
'filename' => 'hindi_india',
),
'hu-HU' =>
array (
'language' => 'Hungarian',
'direction' => 'ltr',
'country' => 'hu',
'filename' => 'hungarian_hungary',
),
'is-IS' =>
array (
'language' => 'Icelandic',
'direction' => 'ltr',
'country' => 'is',
'filename' => 'icelandic_iceland',
),
'id-ID' =>
array (
'language' => 'Indonesian',
'direction' => 'ltr',
'country' => 'id',
'filename' => 'indonesian_indonesia',
),
'ga-IE' =>
array (
'language' => 'Irish',
'direction' => 'ltr',
'country' => 'ie',
'filename' => 'irish_ireland',
),
'it-IT' =>
array (
'language' => 'Italian',
'direction' => 'ltr',
'country' => 'it',
'filename' => 'italian_italy',
),
'ja-JP' =>
array (
'language' => 'Japanese',
'direction' => 'ltr',
'country' => 'jp',
'filename' => 'japanese_japan',
),
'ko-KR' =>
array (
'language' => 'Korean',
'direction' => 'ltr',
'country' => 'kr',
'filename' => 'korean_korea',
),
'lv-LV' =>
array (
'language' => 'Lativan',
'direction' => 'ltr',
'country' => 'lv',
'filename' => 'latvian_latvia',
),
'lt-LT' =>
array (
'language' => 'Lithuanian',
'direction' => 'ltr',
'country' => 'lt',
'filename' => 'lithuanian_lithuania',
),
'mk-MK' =>
array (
'language' => 'Macedonian',
'direction' => 'ltr',
'country' => 'mk',
'filename' => 'macedonian_macedonia',
),
'ms-MY' =>
array (
'language' => 'Malay',
'direction' => 'ltr',
'country' => 'my',
'filename' => 'malay_malaysia',
),
'mt-LT' =>
array (
'language' => 'Maltese',
'direction' => 'ltr',
'country' => 'lt',
'filename' => 'maltese_malta',
),
'no-NO' =>
array (
'language' => 'Norwegian',
'direction' => 'ltr',
'country' => 'no',
'filename' => 'norwegian_norway',
),
'pl-PL' =>
array (
'language' => 'Polish',
'direction' => 'ltr',
'country' => 'pl',
'filename' => 'polish_poland',
),
'pt-PT' =>
array (
'language' => 'Portuguese',
'direction' => 'ltr',
'country' => 'pt',
'filename' => 'portuguese_portugal',
),
'pt-BR' =>
array (
'language' => 'Portuguese (Brazil)',
'direction' => 'ltr',
'country' => 'br',
'filename' => 'portuguese_brazil',
),
'ro-RO' =>
array (
'language' => 'Romanian',
'direction' => 'ltr',
'country' => 'ro',
'filename' => 'romanian_romania',
),
'ru-RU' =>
array (
'language' => 'Russian',
'direction' => 'ltr',
'country' => 'ru',
'filename' => 'russian_russia',
),
'sr-RS' =>
array (
'language' => 'Serbian',
'direction' => 'ltr',
'country' => 'rs',
'filename' => 'serbian_serbia',
),
'sk-SK' =>
array (
'language' => 'Slovak',
'direction' => 'ltr',
'country' => 'sk',
'filename' => 'slovak_slovakia',
),
'sl-SI' =>
array (
'language' => 'Slovenian',
'direction' => 'ltr',
'country' => 'si',
'filename' => 'slovenian_slovenia',
),
'es-ES' =>
array (
'language' => 'Spanish',
'direction' => 'ltr',
'country' => 'es',
'filename' => 'spanish_spain',
),
'sv-SE' =>
array (
'language' => 'Swedish',
'direction' => 'ltr',
'country' => 'se',
'filename' => 'swedish_sweden',
),
'th-TH' =>
array (
'language' => 'Thai',
'direction' => 'ltr',
'country' => 'th',
'filename' => 'thai_thailand',
),
'tr-TR' =>
array (
'language' => 'Turkish',
'direction' => 'ltr',
'country' => 'tr',
'filename' => 'turkish_turkey',
),
'vi-VN' =>
array (
'language' => 'Vietnamese',
'direction' => 'ltr',
'country' => 'vn',
'filename' => 'vietnamese_vietnam',
),
)


Using USER, locale = en-US, country = us

path2locales = /var/www/monitoring/locales
x path2catalogue = /var/www/monitoring/locales/LC_MESSAGES/english_usa.mo
x path2calendar = /var/www/monitoring/include/js/LC_MESSAGES/jquery.ui.datepicker-english_usa.js

Using FALLBACK
+ Using NumberFormatter()

YATV
Posts: 4
Joined: Wed Oct 14, 2015 8:20 pm

Re: PHP warnings

#9 Post by YATV » Fri Apr 19, 2019 3:29 am

Cacti Version 1.2.3
What to do next? How to fix this error?

YATV
Posts: 4
Joined: Wed Oct 14, 2015 8:20 pm

Re: PHP warnings

#10 Post by YATV » Fri Apr 19, 2019 4:12 am

Error in log
Attachments
error.PNG
2019/04/19 06:06:32 - CMDPHP PHP ERROR WARNING Backtrace: (/graph_json.php[158]:rrdtool_function_graph(), /lib/rrd.php[1548]:variable_bandwidth_summation(), /lib/graph_variables.php[674]:number_format_i18n(), /include/global_languages.php[651]:numfmt_set_attribute(), CactiErrorHandler())
2019/04/19 06:06:32 - ERROR PHP WARNING: numfmt_set_attribute() expects parameter 1 to be NumberFormatter, null given in file: /var/www/monitoring/include/global_languages.php on line: 651
error.PNG (140.94 KiB) Viewed 749 times

User avatar
Osiris
Cacti Pro User
Posts: 835
Joined: Mon Jan 05, 2015 10:10 am

Re: PHP warnings

#11 Post by Osiris » Sat Jul 13, 2019 5:56 pm

If you can trace down the Graph Template that is causing this issue, we need to see a screen grab of the Graph Template showing all the summation data. Thanks.
Before history, there was a paradise, now dust.

User avatar
Osiris
Cacti Pro User
Posts: 835
Joined: Mon Jan 05, 2015 10:10 am

Re: PHP warnings

#12 Post by Osiris » Sat Jul 13, 2019 6:07 pm

Looks like this should be fixed in Cacti 1.2.5.
Before history, there was a paradise, now dust.

Post Reply