Skip to content
This repository was archived by the owner on Nov 14, 2024. It is now read-only.
This repository was archived by the owner on Nov 14, 2024. It is now read-only.

Serialization of arrays does not work as expected #23

Open
@morpheouss

Description

@morpheouss

$GLOBALS is an associative array which contains the following value:
Array(10) { [_SERVER] => Array(1) { [SCRIPT_FILENAME] => test.ph7 } [_GET] => Array(0) { } [_POST] => Array(0) { } [_FILES] => Array(0) { } [_COOKIE] => Array(0) { } [_SESSION] => Array(0) { } [_REQUEST] => Array(0) { } [_ENV] => Array(0) { } [_HEADER] => Array(0) { } [argv] => Array(0) { } }

Anyway the following code:
var_dump(unserialize(serialize($GLOBALS)));
produces the following output:
array(10) { [0] => array(1) { [0] => string(8 'test.ph7') } [1] => array(0) { } [2] => array(0) { } [3] => array(0) { } [4] => array(0) { } [5] => array(0) { } [6] => array(0) { } [7] => array(0) { } [8] => array(0) { } [9] => array(0) { } }

As you can see, they array somehow got converted from associative to numeric.

Activity

symisc

symisc commented on Jun 28, 2018

@symisc
Owner

If the target array to serialize is empty, then the serialize() function is a noop.

morpheouss

morpheouss commented on Jun 29, 2018

@morpheouss
Author

Dont you see that in this particular case both $GLOBALS and $GLOBALS['_SERVER'] are not empty arrays? They got converted from associative to numeric and this is IMHO a bug.

morpheouss

morpheouss commented on Jun 30, 2018

@morpheouss
Author

Why close?

reopened this on Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @symisc@morpheouss

      Issue actions

        Serialization of arrays does not work as expected · Issue #23 · symisc/PH7