Framework: Arr::flatten exception in PHP 7.3.0RC3

Created on 21 Oct 2018  ·  28Comments  ·  Source: laravel/framework

  • Laravel Version: 5.7.9
  • PHP Version: 7.3.0RC3
  • Database Driver & Version:

Description:

Arr::flatten produces error "Unsupported operand types"
Possible related issue : https://bugs.php.net/bug.php?id=75533

Steps To Reproduce:

Create a Fresh Laravel App
change the welcome view to
<?php $a=\App\User::all(); ?>
reload browser

Exception in console (php-fpm error log)

[21-Oct-2018 09:08:01 UTC] PHP Fatal error: Uncaught Error: Unsupported operand types in /vendor/laravel/framework/src/Illuminate/Support/Arr.php:219
Stack trace:

0 /vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2706): Illuminate\Support\Arr::flatten(Array)

1 /vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2027): Illuminate\Database\Query\Builder->getBindings()

2 /vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2015): Illuminate\Database\Query\Builder->runSelect()

3 /vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2499): Illuminate\Database\Query\Builder->Illuminate\Database\Query{closure}()

4 /vendor/laravel/framework/sr in /vendor/laravel/framework/src/Illuminate/Support/Arr.php on line 219

Most helpful comment

Tried disabling xdebug and now working fine for me too. Sorry.

Will wait for the final release of xdebug for 7.3 before trying it again.

All 28 comments

I suspect $depth - 1 to cause this when $depth is INF, but I can't reproduce it. What OS are you using?

Fedora - Rawhide, php-7.3 just landed in updates and it broke ever laravel project

packages installed

php-opcache-7.3.0~rc3-1.fc30.x86_64
php-pdo-7.3.0~rc3-1.fc30.x86_64
php-mysqlnd-7.3.0~rc3-1.fc30.x86_64
php-recode-7.3.0~rc3-1.fc30.x86_64
php-process-7.3.0~rc3-1.fc30.x86_64
php-bcmath-7.3.0~rc3-1.fc30.x86_64
php-gd-7.3.0~rc3-1.fc30.x86_64
php-tidy-7.3.0~rc3-1.fc30.x86_64
php-soap-7.3.0~rc3-1.fc30.x86_64
php-cli-7.3.0~rc3-1.fc30.x86_64
php-7.3.0~rc3-1.fc30.x86_64
php-common-7.3.0~rc3-1.fc30.x86_64
php-gmp-7.3.0~rc3-1.fc30.x86_64
php-mbstring-7.3.0~rc3-1.fc30.x86_64
php-json-7.3.0~rc3-1.fc30.x86_64
php-fpm-7.3.0~rc3-1.fc30.x86_64
php-imap-7.3.0~rc3-1.fc30.x86_64
php-xmlrpc-7.3.0~rc3-1.fc30.x86_64
php-xml-7.3.0~rc3-1.fc30.x86_64
php-intl-7.3.0~rc3-1.fc30.x86_64
php-pgsql-7.3.0~rc3-1.fc30.x86_64

It works for me on Windows and Ubuntu.

Do you get the same error from <?php echo INF - 1; ?>?

yes, no error when reinstalled OS with direct install of php-7.3 and not updating from php-7.2

probably some conflicting configuration files

I'm having the exact same problem... Works fine on 7.2, as soon as I upgrade to 7.3.0, I get:

[2018-12-17 18:28:57] testing.ERROR: Failed Reason:/var/www/app/Providers/GlobalExceptionServiceProvider.php {"Reason":"Unsupported operand types"} 
[2018-12-17 18:28:57] testing.ERROR: Unsupported operand types {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Unsupported operand types at /var/www/vendor/laravel/framework/src/Illuminate/Support/Arr.php:219)

@hopeseekr What code is triggering the error? A query?

Does <?php echo INF - 1; ?> work for you?

<?php echo INF -1; ?> returns INF.

The code works on 7.1-7.2, when I upgrade to 7.3.0, it explodes.

When I edit Illuminate\Database\Query\Builder and change it from:

    public function getBindings()
    {
        return Arr::flatten($this->bindings);
    }

to

    public function getBindings()
    {
        return Arr::flatten($this->bindings, 255);
    }

it works fine on PHP 7.3.0.

What OS are you using? Does Arr::flatten([[]]); trigger the same error?

Fresh App in Homestead(Per Project Installation)
Laravel : 5.7.18
vagrant box : 6.4.0
PHP : 7.3.0RC4

Update to PHP7.3.0

sudo apt update
sudo apt upgrade

phpinfo

PHP Version 7.3.0-2+ubuntu18.04.1+deb.sury.org+1

Homestead.yaml

sites:
    -
        map: homestead.test
        to: /home/vagrant/code/public
        php: "7.3"

routes/web.php

Route::get('/', function () {
    \Illuminate\Support\Arr::flatten([[]]);
});

=> Unsupported operand types

echo INF - 1;

=> Unsupported operand types

image

Same issue here.

Unsupported operand types in Arr.php line 219

PHP: 7.3.0
OS: macOS 10.14.2 (Mojave)
Laravel: 5.5

php > echo INF - 1;
INF

This is very weird. I'm using the same Homestead configuration, but I can't reproduce it.

@driesvints Can you reproduce this?

I can't reproduce this locally on my machine. Since we also don't have reports of this on Forge etc I suspect this to be a bug within Homestead itself. Please make sure you're at least running the stable 7.3.0 release and not an RC and open an issue on the Homestead repository.

Actually I don't think this is a Homestead issue but rather something else obscure. Maybe try one of the following channels first:

This is happening to me inside Docker via https://github.com/phpexpertsinc/laravel_quickstart

Definitely not specific to Homestead.

Same issue for me in Docker when using an image built from php:7.3-apache.

I really think this is a configuration issue of some sort and not a Laravel problem because we can't reproduce it. If you can provide the exact setup and PHP configurations for this bug to be reproduced we could have another look.

Hit the same issue on the following system:
Ubuntu 18.04
Laravel 5.6.38
PHP 7.3

In case it's of use to anyone, disabling xdebug resolved the issue for us. Need to dig into it a bit more to understand why...

Anything that works perfectly on PHP 7.2 and not on PHP 7.3 but isn't a documented PHP 7.3 breaking change shouldn't be considered a framework bug.

Tried disabling xdebug and now working fine for me too. Sorry.

Will wait for the final release of xdebug for 7.3 before trying it again.

Thx to @gdhnz 👍

_Same problem with Xdebug (v2.7.0beta1) under Archlinux (4.19.13-1-MANJARO) with Apache (2.4.37) and PHP 7.3.0_

Same error here, but with the 7.3.0 Stable (not the RC one). And on the lastest release of Laravel, the v5.7.19.

<?php echo INF - 1; ?> returns INF.

$ php -v
PHP 7.3.0-2+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Dec 17 2018 09:22:12) ( NTS 

Edit:

eita. Well, can confirm that this issue happens only if php-xdebug is also enabled. My version 2.7.0~beta1+2.6.1+2.5.5-1+ubuntu16.04.1+deb.sury.org+10 (its the lastests from https://xdebug.org/). So, for who comes here from google, thanks to @tuathail & @gdhnz, you can try for now just run the following instead of downgrade from PHP 7.3 to 7.2:

sudo apt remove php-xdebug

Or equivalent.

I too faced the same error on my homestead box when upgraded the project to php 7.3

'Unsupported operand types'

Removing php-xdebug has solved the issue for now.

The latest (unreleased) versions of php 7.3 and xdebug DO WORK now. ;)

PHP 7.3.1RC1 or later + xdebug master (23rd December or later).

I've documented the required versions at https://github.com/laravel/framework/issues/27052.

I'm still having this problem... Although I already updated Homestead and PHP environment.

Homestead v8.0.0
PHP: PHP 7.3.1-1+ubuntu18.04.1+deb.sury.org+1 — cli
Laravel: 5.7.22

Any idea why is this happen?

hey @iamyaoxi , Look at #27030. Have some workarounds there. This comment https://github.com/laravel/framework/issues/27052#issuecomment-456420979 also mention why Homestead have this issue

I'm going to lock this thread because I doubt any further helpful discussion can continue. Please wait with upgrading if you rely on this until a new patch release from PHP and a new xdebug version is released.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shopblocks picture shopblocks  ·  3Comments

Anahkiasen picture Anahkiasen  ·  3Comments

PhiloNL picture PhiloNL  ·  3Comments

kerbylav picture kerbylav  ·  3Comments

Fuzzyma picture Fuzzyma  ·  3Comments