7

I have this custom compiled PHP (v5.3.3) with the following extensions enabled (via configure):

./configure 
--prefix=/usr/local/php5.3.3 
--with-config-file-path=/usr/local/apache2/conf 
--with-apxs2=/usr/local/apache2/bin/apxs 
--with-bz2 
--with-curl=/usr/lib 
--with-curlwrappers 
--with-freetype-dir=/usr/local 
--with-gd=/usr/local 
--with-gettext 
--with-gmp 
--with-iconv=/usr/local 
--with-imap=/usr/local/imap2007e 
--with-imap-ssl 
--with-jpeg-dir=/usr/local/lib 
--with-kerberos 
--with-libxml-dir=/usr/lib 
--with-mcrypt=/usr/local 
--with-mhash 
--with-mysql=/usr/lib/mysql 
--with-mysql-sock=/var/lib/mysql/mysql.sock 
--with-mysqli=/usr/lib/mysql/mysql_config 
--with-openssl=/usr 
--with-pcre-dir=/usr/local/lib 
--with-pear 
--with-png-dir=/usr/local/lib 
--with-readline 
--with-sqlite 
--with-xmlrpc 
--with-xsl=/usr/local 
--with-zlib-dir=/usr/local/lib 
--with-zlib=/usr/local 
--without-pgsql 
--enable-bcmath 
--enable-calendar 
--enable-exif 
--enable-embedded-mysqli=shared 
--enable-ftp 
--enable-gd-jis-conv 
--enable-gd-native-ttf 
--enable-mbstring=all 
--enable-mbregex 
--enable-shared 
--enable-sockets 
--enable-soap 
--enable-sqlite-utf8 
--enable-zend-multibyte 
--enable-zip 
--disable-pdo 
--disable-phar 

phpinfo() clearly states that mbstring is enabled: alt text

Funny thing is when I try to run some PHP scripts (SugarCRM updates), it reports the following error:

PHP Fatal error: Call to undefined function mb_strlen() in crm/include/pclzip/pclzip.lib.php on line 4165

Can anyone throw some light into WHY this is happening and how to fix this?

Thanks, m^e

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
miCRoSCoPiC_eaRthLinG
  • 2,910
  • 4
  • 40
  • 56
  • What version of pclzip are you using? I can't find any use of mb_strlen() in the source anywhere in the last three releases – Mark Baker Nov 17 '10 at 11:14
  • There could possibly be an issue with the load balancing that your servers use. Do you have more than one server? I'd faced a similar issue with the cURL in PHP. – Naweed Chougle Nov 17 '10 at 11:18
  • @Mark: The comments section says PhpConcept Library - Zip Module 2.4. And line 4165 of my version (one that comes with SugarCRM 6.0.0) does contain a mb_strlen(). The code goes like: if (mb_strlen($v_binary_data,'iso-8859-1') != 18). – miCRoSCoPiC_eaRthLinG Nov 18 '10 at 02:20
  • @Jon: No load balancing here :) It's running of a single server on Fedora 13. – miCRoSCoPiC_eaRthLinG Nov 18 '10 at 02:21
  • It's a pretty old version. Latest is 2.8.2. I don't know if the SugarCRM developers have actually changed pclzip, but you might consider upgrading to the 2.8.2 version which isn't dependent on the mb_ functions. – Mark Baker Nov 18 '10 at 09:46

5 Answers5

2

On my Windows system with PHP and Apache, I had to modify the PHP.INI file so that it includes the following line:

extension=php_mbstring.dll

(inside the main [PHP] section) and restart Apache. After that, the call to mb_strlen did succeed.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
2

For PHP 4.3.3 or before, To enable that feature, you will have to supply either one of the following options to the LANG parameter of --enable-mbstring=LANG ; --enable-mbstring=cn for Simplified Chinese support, --enable-mbstring=tw for Traditional Chinese support, --enable-mbstring=kr for Korean support, --enable-mbstring=ru for Russian support, and --enable-mbstring=ja for Japanese support (default). To enable all supported encoding, use --enable-mbstring=all

try

  • configure again with --enable-mbstring only

  • grep mb_strlen $PATH_TO_YOUR_PHP_BINARY to see is it exist

ajreal
  • 46,720
  • 11
  • 89
  • 119
  • My version is PHP 5.3.3. And as you can see from my configure options, all mb_string related options are enabled. I've tried earlier on with just the mbstring option - but same results!! :( – miCRoSCoPiC_eaRthLinG Nov 18 '10 at 02:25
  • A question though.. Will grep mb_strlen yield results at all? Isn't it supposed to be a function in the mbstring library. How will that turn up in grep? – miCRoSCoPiC_eaRthLinG Nov 18 '10 at 02:27
  • If the function not compiled into PHP binary, it return 0 matches. – ajreal Nov 18 '10 at 02:42
  • Hmmm.. grep returns no matches.. "grep mb_strlen /usr/local/php/bin/php --> Binary file /usr/local/php/bin/php matches" :o Then how come phpinfo() is showing the mbstring enabled output ? – miCRoSCoPiC_eaRthLinG Nov 18 '10 at 03:31
  • Actually it means matched, then you would try another debugging method. First, check both (SugarCMS and the phpinfo) are running using same apache and using same PHP ? – ajreal Nov 18 '10 at 03:40
  • oh yep they are :D coz Sugar required a whole bunch of extensions (IMAP and stuff) which I had to compile into my version. An Sugar is able to fetch mails using the IMAP libs. So 100% it is using the version I compiled. IMAP (and several other libs) were missing in the default PHP distro (5.2.x) that came with FC13. – miCRoSCoPiC_eaRthLinG Nov 18 '10 at 10:22
  • Secondly, how about your create a script that just run mb_strlen ? Thirdly, edit the crm/include/pclzip/pclzip.lib.php to replace mb_strlen using suggestion posted here : http://www.php.net/manual/en/function.mb-strlen.php#87114, and re-run the upgrade – ajreal Nov 18 '10 at 11:23
1

I had the same problem, this is an issue with php version.

first run

sudo apt install php-mbstring

to install mbstring to the latest installed version of php

then run:

 sudo apt-get dist-upgrade

and restart apache with

 sudo /etc/init.d/apache2 restart

Good luck

Grigory Ilizirov
  • 1,030
  • 1
  • 8
  • 26
0

Put this phpinfo() in a some php file for the output. And look for MbString seperate box there, if it is not present, then it is not installed properly.

J Bourne
  • 1,409
  • 2
  • 14
  • 33
  • Hello Sai: Please see my question. I have already attached a screenshot the mbstring() section of phpinfo()... From the output, there's no question of it not being installed properly. – miCRoSCoPiC_eaRthLinG Nov 18 '10 at 02:18
-2

Simple solution.

Instead mb_strlen() only use strlen().

To me, it worked a few times.

Mihai Iorga
  • 39,330
  • 16
  • 106
  • 107
  • 3
    I'm afraid this won't help the OP, since strlen() is not always the right choice. if he's application is using html sepcial chars, strlen might cut the string wrong, since strlen() couts the bytes, so if a multibyte characters shows up, it will cut earlier than expected. – Kao Sep 26 '12 at 06:13
  • 1
    It's important to pass encoding because some UTF-8 chars are saved in 2 bites - strlen won't produce the same output as mb_strlen in some cases – Mr.TK Jun 09 '14 at 06:08