mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-28 15:56:02 +03:00
$data
Unsupported operand types error fix
the operator `+=` only works like `array_merge ($left, $right) ;` if both variables are arrays
This commit is contained in:
parent
57f5ee3783
commit
cf3ca86246
@ -36,9 +36,18 @@ try {
|
||||
if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) {
|
||||
$raw = file_get_contents('php://input') ?: '';
|
||||
$data = json_decode($raw, true);
|
||||
// $data += will cause 'Unsupported operand types' Fatal error on `null`
|
||||
// check if decoded data is an array (or stdobject) - not null
|
||||
// if any kind of data is present we don't want to lose it
|
||||
if ($data === null) {
|
||||
$data = [];
|
||||
}
|
||||
} else {
|
||||
$data = $_REQUEST;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$data += ['query' => null, 'variables' => null];
|
||||
|
||||
if (null === $data['query']) {
|
||||
|
Loading…
Reference in New Issue
Block a user