Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class_parents(): object or string expected at ../vendor/laravel/framework/src/Illuminate/Support/helpers.php:92 #32479

Closed
nnerijuss opened this issue Apr 21, 2020 · 3 comments
Labels

Comments

@nnerijuss
Copy link

nnerijuss commented Apr 21, 2020

  • Laravel Version: 7.7.0
  • PHP Version: 7.4
  • Database Driver & Version: Mysql 8

Description:

PHP throws exception when refreshing model:

class_parents(): object or string expected at /var/www/laravel/vendor/laravel/framework/src/Illuminate/Support/helpers.php:92)
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Support/helpers.php(92): class_parents()
#2 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1184): class_uses_recursive()
#3 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Support/Traits/EnumeratesValues.php(669): Illuminate\\Database\\Eloquent\\Model->Illuminate\\Database\\Eloquent\\{closure}()
#4 [internal function]: Illuminate\\Support\\Collection->Illuminate\\Support\\Traits\\{closure}()
#5 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Support/Arr.php(647): array_filter()
#6 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Support/Collection.php(352): Illuminate\\Support\\Arr::where()
#7 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Support/Traits/EnumeratesValues.php(671): Illuminate\\Support\\Collection->filter()
#8 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1185): Illuminate\\Support\\Collection->reject()
#9 ... Illuminate\\Database\\Eloquent\\Model->refresh()
...

Steps To Reproduce:

  1. Load model without relationships $model = Model::find(1)
  2. Refresh it $model->refresh()

I think the problem is in Model.php refresh function:

$this->load(collect($this->relations)->reject(function ($relation) {
            return $relation instanceof Pivot
                || in_array(AsPivot::class, class_uses_recursive($relation), true);
})->keys()->all());
@drfraker
Copy link
Contributor

Can confirm this is happening to me too.

PHP 7.4
Laravel 7.7.0
Mysql 8

Reverted back to 7.6 and it is not happening

@driesvints
Copy link
Member

Thanks for reporting. This was due to #32420

We're looking into a fix atm.

@driesvints driesvints added the bug label Apr 21, 2020
@taylorotwell
Copy link
Member

Releasing patch now.

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

No branches or pull requests

4 participants