DirectoryTree / Authorization

Easy, native Laravel user authorization.
MIT License
162 stars 7 forks source link

The script tried to access a property on an incomplete object #2

Closed benjivm closed 2 years ago

benjivm commented 2 years ago

In the process of switching from Larapacks to DirectoryTree and failing at the composer require, I've tried blowing away my vendor/ and re-installing with no luck:

Generating optimized autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   ErrorException

  DirectoryTree\Authorization\PermissionRegistrar::register(): The script tried to access a property on an incomplete object. Please ensure that the class definition "Larapacks\Authorization\Permission" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition

  at [...]\vendor\directorytree\authorization\src\PermissionRegistrar.php:46
     42▕     public function register()
     43▕     {
     44▕         // Dynamically register permissions with Laravel's Gate.
     45▕         foreach ($this->getPermissions() as $permission) {
  ➜  46▕             $this->gate->define($permission->name, function ($user) use ($permission) {
     47▕                 return $user->hasPermission($permission);
     48▕             });
     49▕         }
     50▕     }

  1   [...]\vendor\directorytree\authorization\src\PermissionRegistrar.php:46
      Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("DirectoryTree\Authorization\PermissionRegistrar::register(): The script tried to access a property on an incomplete object. Please ensure that the class definition "Larapacks\Authorization\Permission" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition", "[...]\vendor\directorytree\authorization\src\PermissionRegistrar.php")

  2   [...]\vendor\directorytree\authorization\src\AuthorizationServiceProvider.php:26
      DirectoryTree\Authorization\PermissionRegistrar::register()
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
stevebauman commented 2 years ago

Hi @benjivm,

Are you using dev-master or did you composer update to v1.0.0?

stevebauman commented 2 years ago

Also I would try flushing cache and try running again. I'm assuming your cache contains old Larapacks permission objects and it is failing to unserialize them.

benjivm commented 2 years ago

It was my Redis cache, thank you, should add that to my normal troubleshooting steps!