php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68644 strlen incorrect : mbstring + func_overload=2 + UTF-8 + Opcache
Submitted: 2014-12-24 07:59 UTC Modified: -
From: e dot furmanyuk at timeweb dot ru Assigned:
Status: Closed Package: opcache
PHP Version: 5.6.4 OS: Ubuntu, Centos
Private report: No CVE-ID:
 [2014-12-24 07:59 UTC] e dot furmanyuk at timeweb dot ru
Description:
------------
Greetings.

If set in php.ini 
mbstring.func_overload=2
mbstring.internal_encoding="UTF-8"
or in .htaccess
php_value mbstring.func_overload 2
php_value mbstring.internal_encoding UTF-8

And set enable extension mbstring and opcache.

And after all run the script, the result will be the first implementation of the correct result, but subsequent executions F5 will give an incorrect result.
Strlen not overload by mb_strlen.
Other function such as substr and strtolower and etc work perfectly.
If you disable opcahe problem disappears.

Test script:
---------------
<?php
echo "strlen = ".strlen("\xd0\xa2\xd0\xa2\xd0\xa2\xd0\xa2\xd0\xa2\xd0\xa2")."\n<br>" ;
echo "mb_strlen = ".mb_strlen ("\xd0\xa2\xd0\xa2\xd0\xa2\xd0\xa2\xd0\xa2\xd0\xa2")."\n<br>";
?>

Expected result:
----------------
6
6

Actual result:
--------------
12
6

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-24 09:31 UTC] e dot furmanyuk at timeweb dot ru
this part:

or in .htaccess
php_value mbstring.func_overload 2
php_value mbstring.internal_encoding UTF-8

is mistake. we are talking only about the php.ini.
 [2014-12-24 10:37 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bba4a8aad52df652c95dfd1d7e2289d479b23b99
Log: Fixed bug #68644 (strlen incorrect : mbstring + func_overload=2 +UTF-8 + Opcache)
 [2014-12-24 10:37 UTC] laruence@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Feb 26 21:01:35 2017 UTC