Created
June 29, 2016 18:15
-
-
Save parf/6de34ab52a3573a70abd073ede61a3bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$source = <<< DATA_END | |
M`````A04!@`4`1$#9V5O%`(&``Q`01EW"B*8L08!#,!=ICH^P"\P!@$4`0X` | |
M%`(&``Q`0OBRJ%Y8>P8!#,!>F/<\=W^3!@(4`0X`%`(&``Q`0M:]F'QC*`8! | |
M#,!>G2)#(.<`!@,4`0X`%`(&``Q`/?5B*!-$@`8!#,!6A.V=_:QI!@04`0X` | |
M%`(&``Q`1Z/7"CUPI`8!#,!>L*/7"CUQ!@44`0X`%`(&``Q`0/7,*[T=+`8! | |
M#,!=7))ER+&U!@84`0X`%`(&``Q`0J9F9F9F9@8!#,!>?KA1ZX4?!@<4`0X` | |
M%`(&``Q`0-^)P;5!E@8!#,!==Q&1(?O3!@@4`0X`%`(&``Q`0.`K^*Q.J`8! | |
M#,!=?YV1"G[?!@D4`0X`%`(&``Q`/79UYC8J7@8!#,!7UNE?JHJ#!@H4`0X` | |
M%`(&``Q`/9Y780_E4`8!#,!7YOG>Z2\#!@L4`0X`%`(&``Q`0WI<82GF@P8! | |
M#,!3/(.0KCB-!@P4`0X`%`(&``Q`0MDK(#\ZJ`8!#,!85=@TW]N=!@T4`0X` | |
M`0X&#A0!#@`!#@8/%`$.``$.!A`4`0X`%`(&``Q`12+(A&BO[08!#,!1\)"( | |
MY#^P!A$4`0X`%`(&``Q`0N+O2"'7P08!#,!>C;>>TKY^!A(4`0X`%`(&``Q` | |
M16[?I#_ER08!#,!5>7]BMJY]!A,4`0X`%`(&``Q`12<\UDHD$08!#,!1Q4<+ | |
#PJOB | |
DATA_END; | |
$igbinary_data = convert_uudecode($source); | |
echo "PHP7 can't igbinary_unserialize this data\n"; | |
$data = igbinary_unserialize($igbinary_data); // works in PHP5, does not work in PHP7 <<< BUG IS HERE !!! | |
if ($data === null) | |
die("igbinary_unserialize failed"); | |
echo json_encode($data), "\n"; | |
$igb_data2 = igbinary_serialize($data); | |
if ($igb_data2 === $igbinary_data) | |
echo "igbinary_serialize(\$data) is the same as original-source;\n"; | |
$igb_data3 = igbinary_serialize(json_decode(json_encode($data), 1)); | |
if ($igb_data3 !== $igbinary_data) | |
echo "* igbinary_serialize(json_encode(json_decode(\$original))) is not the same as igbinary_serialize(\$original);\n"; | |
$igb_data4 = igbinary_serialize(unserialize(serialize($data))); | |
if ($igb_data4 !== $igbinary_data) | |
echo "* igbinary_serialize(unserialize(serialize(\$original))) is not the same as igbinary_serialize(\$original);\n"; | |
$data3 = igbinary_unserialize($igb_data3); | |
if (serialize($data3) === serialize($data)) | |
echo "actual data is exactly the same: igbinary_unserialize(igbinary_serialize(serialize(unserialize(\$original)))) === \$original\n"; | |
// If you save igb_data3 it works with PHP7 | |
// igbinary_serialize(unserialize(serialize($data)) will make data compatible with PHP7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> php igbinary-fail.php | |
PHP7 can't igbinary_unserialize this data | |
[{"geo":[34.1989453,-118.597305]},{"geo":[37.9429522,-122.3900901]},{"geo":[37.677661,-122.4552162]},{"geo":[29.958529,-90.077003]},{"geo":[47.28,-122.76]},{"geo":[33.9202933,-117.4464354]},{"geo":[37.3,-121.98]},{"geo":[33.7463915,-117.8604472]},{"geo":[33.7513419,-117.9939921]},{"geo":[29.4627365,-95.357994]},{"geo":[29.6185208,-95.6090009]},{"geo":[38.9559442,-76.9455301]},{"geo":[37.6966286,-97.3413212]},{"geo":[37.3,-121.98]},{"geo":[37.3,-121.98]},{"geo":[37.3,-121.98]},{"geo":[42.2717443,-71.7588217]},{"geo":[37.7729273,-122.2143323]},{"geo":[42.8662,-85.8984]},{"geo":[42.3065441,-71.0824613]}] | |
igbinary_serialize($data) is the same as original-source; | |
* igbinary_serialize(json_encode(json_decode($original))) is not the same as igbinary_serialize($original); | |
* igbinary_serialize(unserialize(serialize($original))) is not the same as igbinary_serialize($original); | |
actual data is exactly the same: igbinary_unserialize(igbinary_serialize(serialize(unserialize($original)))) === $original | |
> php -v | |
PHP 5.6.20 (cli) (built: Mar 31 2016 07:01:09) | |
Copyright (c) 1997-2016 The PHP Group | |
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies | |
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> php ./igbinary-fail.php | |
PHP7 can't igbinary_unserialize this data | |
Warning: igbinary_unserialize_ref: invalid reference in /rd/rd/scripts/bench/igbinary-fail.php on line 21 | |
Call Stack: | |
0.0001 354048 1. {main}() /rd/rd/scripts/bench/igbinary-fail.php:0 | |
0.0001 354720 2. igbinary_unserialize() /rd/rd/scripts/bench/igbinary-fail.php:21 | |
igbinary_unserialize failed | |
> php -v | |
PHP 7.0.7 (cli) (built: May 25 2016 17:47:24) ( NTS ) | |
Copyright (c) 1997-2016 The PHP Group | |
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies | |
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies | |
same issue with: | |
> php -v | |
PHP 7.0.8 (cli) (built: Jun 22 2016 11:15:33) ( NTS ) | |
Copyright (c) 1997-2016 The PHP Group | |
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment