Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Uncaught Error: Unsupported operand types in <app>/vendor/bugsnag/bugsnag-silex/src/Request/SilexRequest.php:74 #19

Closed
dominics opened this issue Mar 21, 2017 · 1 comment

Comments

@dominics
Copy link

In SilexRequest, this library does the following:

$data['params'] = $this->getInput() + $this->request->query->all();

The call to $this->request->query->all() will always return an array - so far so good. But, in the case of a JSON request payload, the return type of getInput() can be anything that json_decode returns (and is under the control of the client):

// in getInput()
if (is_array($parsed = json_decode($this->request->getContent(), true))) {
    return $parsed;
}

While some versions of JSON (e.g. https://tools.ietf.org/html/rfc4627: "A JSON text is a serialized object or array") specify that a JSON document must contain an object or array, PHP's json_decode has never followed this. So, the return value of json_decode() can be a bool, string, float, int, etc.

Using the + operator between a string and array causes a warning. Using the + operator between an int and array causes a fatal error:

Uncaught Error: Unsupported operand types in <app>/vendor/bugsnag/bugsnag-silex/src/Request/SilexRequest.php:74
Stack trace:
#0 <app>/vendor/bugsnag/bugsnag/src/Callbacks/RequestMetaData.php(38): Bugsnag\Silex\Request\SilexRequest->getMetaData()
#1 <app>/vendor/bugsnag/bugsnag/src/Middleware/CallbackBridge.php(40): Bugsnag\Callbacks\RequestMetaData->__invoke(Object(Bugsnag\Report))
#2 [internal function]: Bugsnag\Middleware\CallbackBridge->__invoke(Object(Bugsnag\Report), Object(Closure))
[...]
@dominics
Copy link
Author

Closing because I didn't notice the is_array - this bug came from running 2.1.0 I think; not 2.1.1. Apologies.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant