[2.1] File PRG plugin issue when merging POST data with nested keys #3370

Closed
cgmartin opened this Issue Jan 7, 2013 · 6 comments

Comments

Projects
None yet
4 participants
Contributor

cgmartin commented Jan 7, 2013

When $_POST and $_FILES share the same nested keys, the merge will overwrite and lose data.

https://github.com/zendframework/zf2/blob/develop/library/Zend/Mvc/Controller/Plugin/FilePostRedirectGet.php#L88

$post = array(
    "business" => array(
        "name" => "BigCompany"
    )
);
$files = array(
    "business" => array(
        "logo" => array(
            "name" => "400.png",
            "type" => "image/png",
            "tmp_name" => "/tmp/php5Wx0aJ",
            "error" => 0,
            "size" => 15726,
        )
    )
);
// Results in the FilePostRequestGet plugin overwriting the $_POST["business"]["name"] :
/*
Array
(
    [business] => Array
        (
            [logo] => Array
                (
                    [name] => 400.png
                    [type] => image/png
                    [tmp_name] => /tmp/php5Wx0aJ
                    [error] => 0
                    [size] => 15726
                )
        )
)
*/

/cc @hamlis who originally found this issue.

Contributor

cgmartin commented Jan 19, 2013

Saw the note about ZF 2.1.0 feature freeze and release on Jan 29th. Will work on a fix for this.

Contributor

macnibblet commented Jan 22, 2013

Ah awesome been waiting for a fix for this one, now i can clean up my messy code 💃

weierophinney added a commit that referenced this issue Jan 22, 2013

Owner

weierophinney commented Jan 22, 2013

Closed with #3510

Contributor

cgmartin commented Jan 22, 2013

@radnan awesome! Thanks for the fix, beat me to it :)

Contributor

radnan commented Jan 22, 2013

@cgmartin oops, haha np. Didn't mean to step on any toes.

Contributor

cgmartin commented Jan 22, 2013

No toes were harmed. Love it when things get fixed. Even better when it saves my time. :) Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment