Negotiation: E_WARNING: array_map(): An error occurred while invoking the map callback
After deploying the negotiation library as part of FriendsOfSymfony/FOSRestBundle version 2.0.0 we started to get
E_WARNING: array_map(): An error occurred while invoking the map callback
from Negotiation\AbstractNegotiator::getBest() (27 or 28). I assume this happens because Negotiation\Accept::__construct() may throw an exception when constructed with an invalid value. This in turn seems to trigger PHP bug #55416 causing a warning to be emitted.
I don’t know which exact value seems to cause this problem as the issue is not reproducible and only happens sparsely on our live servers - most often with some Android phones.
Can this part be rewritten somehow to circumvent PHP bug #55416? Or can the logic be implemented a little bit more tolerant to weird values coming in from web clients?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 26 (26 by maintainers)
Commits related to this issue
- Fix potential E_WARNING because of array_map() Fix #81 — committed to willdurand/Negotiation by willdurand 8 years ago
- Merge pull request #84 from sgehrig/issue-81-2 BC break? - Fix for issue #81 - silently skip invalid header values coming in from clients — committed to willdurand/Negotiation by willdurand 8 years ago
Great. I fixed the issue I guess.
Just released Negotiation 2.0.3
@willdurand: Updated my comment - sometimes I should think to the end before writing a comment 😉 You’re right, logically it’s more likely that the bug is in Negotiation.
Hi @sgehrig, that’s definitely not cool, and I am sorry for that.
There are only two occurences of the
array_map()function: https://github.com/willdurand/Negotiation/blob/5154ac7346ed2821dd55e2b70cb865d54f7cbca7/src/Negotiation/AbstractNegotiator.php#L27-L28. Without any test data, it seems complicated to come up with a fix but I am going to investigate which data might trigger such a warning using the test suite.