[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-qa
Subject:    [PHP-QA] Bug #70289 [Com]: Different sort in php7 (and hhvm) compared to php5
From:       "kjarli at gmail dot com" <php-bugs () lists ! php ! net>
Date:       2015-08-18 8:22:41
Message-ID: 201508180822.t7I8MfgB020325 () sgrv20 ! php ! net
[Download RAW message or body]

Edit report at https://bugs.php.net/bug.php?id=70289&edit=1

 ID:                 70289
 Comment by:         kjarli at gmail dot com
 Reported by:        kjarli at gmail dot com
 Summary:            Different sort in php7 (and hhvm) compared to php5
 Status:             Feedback
 Type:               Bug
 Package:            Testing related
 Operating System:   Ubuntu 14.04
 PHP Version:        7.0.0beta3
 Block user comment: N
 Private report:     N

 New Comment:

This report seems related: https://bugs.php.net/bug.php?id=40888

If it's not a bug and indeed related to small arrays in php7, I would rather see a \
small notice in the upgrade guide than to have people "waste" time on such a trivial \
"issue" as it's much better to rely on defined behavior by the developer.


Previous Comments:
------------------------------------------------------------------------
[2015-08-18 08:19:51] requinix@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.

Sounds like cweiske's right. PHP's sorting has never promised that equal elements \
will appear in any particular order. Also know that PHP 7 uses a different sorting \
algorithm for small arrays than it does larger arrays.

------------------------------------------------------------------------
[2015-08-18 08:14:40] cweiske@php.net

I saw the same in the PEAR core unit tests.

This only happens when the elements are equal. Since they are equal, the order of the \
elements is unspecified and dependent on the internal implementation and the sort \
algorithm.

Not a bug in my eyes.

------------------------------------------------------------------------
[2015-08-18 08:08:13] kjarli at gmail dot com

Description:
------------
I haven't gotten a proper test setup, but I do have the travis builds. I was working \
on a priority sorting feature and I had added a test to verify sort orders. On php5 \
it consistently went right, but on php7 and hhvm it was in reversed order. I fixed it \
by adding a secondary sort (strcmp).

Build #45 (failed):
https://travis-ci.org/iltar/http-bundle/builds/76059069

Build #46 (failed):
https://travis-ci.org/iltar/http-bundle/builds/76061283

Build #47 (fixed):
https://travis-ci.org/iltar/http-bundle/builds/76062321

The test in question:
https://github.com/iltar/http-bundle/blob/feature/property-accessor/test/DependencyInjection/DecorateRouterPassTest.php#L72-L112


It's about the one with a priority of 50, which is reversed as you can see in the \
failed output. 


Test script:
---------------
https://github.com/iltar/http-bundle/blob/feature/property-accessor/test/DependencyInjection/DecorateRouterPassTest.php#L72-L112


Expected result:
----------------
I expect to see consistent sorting, but that was not the case.

sequence:
app.henk2_50
app.henk_50

Actual result:
--------------
sequence:
app.henk_50
app.henk2_50


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70289&edit=1

-- 
PHP Quality Assurance Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic