PHP Bug #63281 (bugs.php.net)

6 points by brownheezo ↗ HN
I came across an interesting "quirk" the other day, while using PHP. If bugs are considered complicated, is it commonplace to just mark them as "WONTFIX"? Shouldn't it, at least, be documented as something to be fixed in the future?

5 comments

[ 4.0 ms ] story [ 33.0 ms ] thread
I don't see how this is a bug?

The bug reporter is using the wrong method, as identified by the first comment.

But the behavior is both counter-intuitive and wrong.

And the resolution is "won't fix" because it's "too hard."

You need to understand that English is not the first language for many developers, so taking snippets like that literally really isn't fair. It isn't a "won't fix" because fixing it is hard, the "hard problem" refers to it being a bit hard to explain for him. He explained nicely why this isn't a bug in his native language.
behaviour is not wrong. bindParam method requires a variable reference not a value. all passed references are replaced on execute. so the behaviour is not unexpected.
The problem is that `bindparam` binds by reference, and `foreach` reuses the same variable for `$value`, with the same reference, in the loop?

Then the solution could be to use `&$value` instead. Untested:

    foreach( $bind_params as $key => &$value ){
      $statement->bindParam($key, $value);
    }
    unset($value);
BTW The fact that you need to manually break the connection between the loop variable and the array item value using `unset` is a bug, in my opinion.