php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67745 regression in RC2: failing test with Atoum, not failing with php 5.4 and 5.5
Submitted: 2014-08-02 09:29 UTC Modified: 2014-08-02 13:47 UTC
From: pascal dot chevrel at free dot fr Assigned: tyrael (profile)
Status: Not a bug Package: *General Issues
PHP Version: 5.6.0RC2 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: pascal dot chevrel at free dot fr
New email:
PHP Version: OS:

 

 [2014-08-02 09:29 UTC] pascal dot chevrel at free dot fr
Description:
------------
I have a test failing with PHP 5.6RC2, I don't know if it is a bug in Atoum or if it exposes a regression in the upcoming PHP 5.6 release.

I put a repo online with a reduced test case exposing the bug:
https://github.com/pascalchevrel/atoumbug_php5.6

I also filed a bug on Atoum:
https://github.com/atoum/atoum/issues/346



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-08-02 10:16 UTC] tyrael@php.net
-Status: Open +Status: Feedback -PHP Version: 5.6.0RC3 +PHP Version: 5.6.0RC2 -Assigned To: +Assigned To: tyrael
 [2014-08-02 10:16 UTC] tyrael@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2014-08-02 10:18 UTC] pascal dot chevrel at free dot fr
-Status: Feedback +Status: Assigned
 [2014-08-02 10:18 UTC] pascal dot chevrel at free dot fr
There is a testcase in a github repo referenced in this bug.
 [2014-08-02 11:05 UTC] tyrael@php.net
yeah, I've seen it, and it depends on atoum, and it makes the work for us easier if we don't have to get ourself familiar with each and every php project to be able to find out what exactly causes the problem,
I've went ahead and created a simple reproduce script based on your repo:

<?php
$sentence = 'Le système le style du couteau du suisse';
$words = explode(' ', $sentence);
$words = array_filter($words); // filter out extra spaces
$words = array_unique($words); // remove duplicate words
// sort words from longest to shortest
usort(
        $words,
        function ($a, $b) {
                return mb_strlen($b) - mb_strlen($a);
        }
);

var_dump($words);
 [2014-08-02 11:05 UTC] tyrael@php.net
-Status: Assigned +Status: Verified
 [2014-08-02 11:23 UTC] tyrael@php.net
-Status: Verified +Status: Not a bug
 [2014-08-02 11:23 UTC] tyrael@php.net
the result of the sort is different, because mb_strlen returns a different value on 5.6, because the default mb_internal_encoding was changed in 5.6 from ISO-8859-1 to UTF-8:
http://3v4l.org/rZNL4
this change is described in our UPGRADING guide and should be explained in the php.net upgrading docs also:
http://git.php.net/?p=php-src.git;a=blob;f=UPGRADING;h=7a174c47c2a034ac3718cf364cde66569d72b0d7;hb=refs/heads/PHP-5.6#l80
if you want to make sure that your code/test produces the same result on both 5.6 and older versions (or anywhere where the internal encoding is set to a non-default value), consider explicitly passing the second optional $encoding argument to mb_strlen()
 [2014-08-02 13:47 UTC] pascal dot chevrel at free dot fr
Thanks for investigating, I see that the bug was in my code as I do have mb_internal_encoding('UTF-8') in the bootstrap file for the application but I don't have it set in the bootstrap file used in my unit tests.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Nov 05 00:01:27 2024 UTC