[ZBX-7949] Multi byte string support Created: 2014 Mar 17  Updated: 2017 May 30  Resolved: 2014 Apr 29

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A), Frontend (F)
Affects Version/s: 2.2.3rc1, 2.3.0
Fix Version/s: 2.3.0

Type: Incident report Priority: Major
Reporter: Pavels Jelisejevs (Inactive) Assignee: Ivo Kurzemnieks
Resolution: Fixed Votes: 0
Labels: api, frontend, mbstring, multibyte, strings
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates ZBX-6939 PHP extension mbstring is mandatory, ... Closed
is duplicated by ZBX-7935 Cannot create trigger if item key con... Closed
is duplicated by ZBX-7937 Hierarchical script names are validat... Closed
is duplicated by ZBX-7938 Macros in graph names are resolved in... Closed

 Description   

There are several problems with handling multi byte strings in the frontend.
1. The frontend cannot properly work with mbstring.func_overload enabled. We must require it to be disabled.
2. We need to review the usages of the PHP string functions and our zbx wrappers and replace them with mbstring functions. Since we require mb string to be enabled, our zbx wrappers must be removed.
3. For mb string functions to work properly we must set the internal encoding to UTF-8.



 Comments   
Comment by Ivo Kurzemnieks [ 2014 Apr 04 ]

During development another bug was found in log trigger expression wizard (tr_logform.php). I had several expressions with type 'include' and all had one or many multibyte characters. Once I added another expression with type 'exclude' and moved it to first position, I got an error about incorrect trigger expression. It turned out that on some occasions it used strlen() instead of mb_strlen(). So this will also be fixed as well.

Comment by Ivo Kurzemnieks [ 2014 Apr 04 ]

(1)
Removed strings:

  • UTF-8

Added strings:

  • PHP string function overloading must be disabled.
  • PHP mbstring.func_overload

Eduards CLOSED

Comment by Ivo Kurzemnieks [ 2014 Apr 04 ]

Now since we require mbstring to be enabled and we no longer have fallback to simple string functions, if mbstring is disabled there will be PHP fatal error. In case mbstring.func_overload has incorrect value, in Monitoring > Dashboard > Status of Zabbix (and Reports > Status of Zabbix) will display an error. In frontend installation if mbstring functions are disabled, mbstring.func_overload option will remain hidden untill the mbstring functions are enabled.

The reason for this is that mbstring.func_overload returns boolean value false if mbstring functions are disabled. However it returns a value set in php.ini if mbstring functions are enabled. Note that mbstring.func_overload value represents a combination of bitmasks.

Notes on function usage:

  • mb_convert_case requires a second parameter, but functions mb_strtolower and mb_strtoupper do not. For better readability it was chosen to replace mb_convert_case with these functions.
  • In most cases mb_strtolower was chosen over mb_strtoupper since most names start with capital letters, followed by many lowercase letters and converting all string to uppercase was found to be ineffective.
  • Having a requirement to check multibyte case-insensitive strings, functions mb_strtolower and mb_strpos were used.
  • Since there cannot be any multibyte PHP file names, extentions and URL parameter names, class Curl does not require to parse strings with mbstring functions.
  • Function strstr() was found less effective than substr() and there was no need to return a part of string. Since it was only required to determine if part of a string was found, function strpos() was used which should now work ~30% faster.
  • Usage of function encode_log() was found to be redundant since history data is read from DB, not directly from file. It already contains UTF-8 format.
  • There are two functions _json_encode() and _json_decode() and they can be used instead of native PHP json functions. Due to internal encoding set to ASCII and afterwards back to UTF-8 before we call these functions, mbstring functions were not used there, because they would give same results as normal string functions.
Comment by Ivo Kurzemnieks [ 2014 Apr 04 ]

RESOLVED in svn://svn.zabbix.com/branches/dev/ZBX-7949

Comment by Ivo Kurzemnieks [ 2014 Apr 24 ]

(2) In ZBX-7981 (4) we noticed that there's a problem when comparing inherited graphs. Since we can create graphs with names "A" and "a" and they are treated as different, I removed case insensitive comparison in graphs and graph prototypes. See r44779

Eduards CLOSED

Comment by Eduards Samersovs (Inactive) [ 2014 Apr 28 ]

(3) As we discussed row highlighting not work in Log history screen. Also please return this code:

$data['value'] = trim($data['value'], "\r\n");

iivs RESOLVED in r44948
Eduards CLOSED

Comment by Eduards Samersovs (Inactive) [ 2014 Apr 29 ]

(4) class.globalregexp.php:205 typo in variable name "$paterns".

iivs RESOLVED in r44932
Eduards CLOSED

Comment by Eduards Samersovs (Inactive) [ 2014 Apr 29 ]

(5) Please return previous formatting in triggers.inc.php:2302

iivs Ok, but just this once. RESOLVED in r44934
Eduards CLOSED

Comment by Eduards Samersovs (Inactive) [ 2014 Apr 29 ]

(6) zbx_stripos() still is used in search.php:206,464

iivs Since host and template names can't contain any multibyte chars, decided not to use mb functions there. RESOLVED in r44937
Eduards CLOSED

Comment by Eduards Samersovs (Inactive) [ 2014 Apr 29 ]

Tested

Comment by Ivo Kurzemnieks [ 2014 Apr 29 ]

Overview of things done:

  • zbx string wrapper functions are now removed and usages of them are replaced with string and/or mbstring functions accordingly;
  • frontend now will display fatal error in case mbstring functions are disabled;
  • a warning will be displayed in "Status of Zabbix" block if mbstring overload is enabled;
  • additionaly fixed inherited graph and graph prototype case insensitive name comparison.

Implemented and fixed in pre-2.3.0 (trunk) r44967

Comment by Martins Valkovskis [ 2014 May 16 ]

Updated documentation:

Comment by Alexander Vladishev [ 2014 May 21 ]

(7) Cannot update trigger prototype. Occurs nothing when clicking the [Save] button.

iivs RESOLVED in svn://svn.zabbix.com/branches/dev/ZBX-7949 r45730

sasha Successfully TESTED!

iivs CLOSED.

Comment by Ivo Kurzemnieks [ 2014 May 22 ]

Fixed in pre-2.3.0 (trunk) r45735

Comment by richlv [ 2014 May 29 ]

this caused a regression with filters : ZBX-8276

Comment by Pavels Jelisejevs (Inactive) [ 2014 Jun 12 ]

This caused a regression: the "case-sensitive" option in regular expressions worked in an opposite way. Will be fixed in ZBX-2603.

Generated at Fri Jun 06 20:33:54 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.