laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.28k stars 10.94k forks source link

L5.2: User table does not allow extra fields, L5.2 core dumps when adding/updating #16652

Closed MichaelA070 closed 7 years ago

MichaelA070 commented 7 years ago

Description:

L5.2: User table does not allow extra fields, L5.2 core dumps when adding/updating; I'm working on a webbased program where I need to have a login routine using a simple setup using like the following; admin, superuser, sales for this i've added two additional columns to the Users table labelled: is_admin (int), role (varchar(20)) when trying to add or update a user now Laravel/PHP crashes and gives an core-dump message in the Apache log file. The 'mass fill' option already has all required fields. No luck getting this working.

Another approach i've tried is following a simple setup of two tables Users (in its original form) and a 'hasOne' table for Roles (with again a minimal setup being) - id, user_id, role, is_admin. Also now when trying to User::create (new user) or update like below snip-it - no luck again (core-dump)

public function update(AUser $user)
{
    $dbUser = $this->byId( new UserId($user->user_id()) );

    $dbRole = Role::find($user->user_id());
    $dbRole->fill([
        'user_id' => $user->user_id(),
        'role' => $user->role(),
        'is_admin' => $user->is_admin()
    ]);

    $dbUser->fill([
        'name' => $user->name(),
        'password' => bcrypt($user->password()),
        'email' => $user->email()
    ]);
    $dbUser->save();
}

Steps To Reproduce:

sisve commented 7 years ago

Segmentation faults are often caused by endless recursive calls. You could try and pinpoint the location/pattern with xdebug's xdebug.max_nesting_level.

KKSzymanowski commented 7 years ago

To continue what Simon said, segmentation faults are very rarely caused by Laravel itself.

Try running it with a different version of PHP or through console(php artisan tinker).

As for nesting level, I think PHP would throw an error saying something like Maximum nesting level of 100 exceeded, I never got a segfault from that. Try disabling xDebug if you have it enabled in your php.ini and check again.

themsaid commented 7 years ago

Please upgrade to Laravel 5.3, your version of Laravel is not supported anymore.

Closing this, feel free to ping me in case you could regenerate the issue on a 5.3 instance, I also suggest that you post your question on the forums, we try to keep this repo for bug reporting only.