Laravel script tries to call method on incomplete object
P粉790819727
P粉790819727 2023-11-12 23:40:29
0
1
677

I just upgraded from v8 to Laravel 9 and suddenly I started getting this error,

Error: The script tried to call a method on an incomplete object. Please ensure that the class definition "LaravelSerializableClosureSerializableClosure" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition #35 /vendor/laravel/framework/src/Illuminate/Queue/CallQueuedClosure.php(68): IlluminateQueueCallQueuedClosure::handle #34 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): IlluminateContainerBoundMethod::IlluminateContainer{closure} #33 /vendor/laravel/framework/src/Illuminate/Container/Util.php(40): IlluminateContainerUtil::unwrapIfClosure #32 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): IlluminateContainerBoundMethod::callBoundMethod #31 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): IlluminateContainerBoundMethod::call #30 /vendor/laravel/framework/src/Illuminate/Container/Container.php(610): IlluminateContainerContainer::call #29 /vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(128): IlluminateBusDispatcher::IlluminateBus{closure} #28 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): IlluminatePipelinePipeline::IlluminatePipeline{closure} #27 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): IlluminatePipelinePipeline::then #26 /vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(132): IlluminateBusDispatcher::dispatchNow #25 /vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(118): IlluminateQueueCallQueuedHandler::IlluminateQueue{closure} #24 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): IlluminatePipelinePipeline::IlluminatePipeline{closure} #23 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): IlluminatePipelinePipeline::then #22 /vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(120): IlluminateQueueCallQueuedHandler::dispatchThroughMiddleware #21 /vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(70): IlluminateQueueCallQueuedHandler::call #20 /vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): IlluminateQueueJobsJob::fire #19 /vendor/laravel/framework/src/Illuminate/Queue/Worker.php(406): IlluminateQueueWorker::process #18 /vendor/laravel/framework/src/Illuminate/Queue/Worker.php(356): IlluminateQueueWorker::runJob #17 /vendor/laravel/framework/src/Illuminate/Queue/Worker.php(158): IlluminateQueueWorker::daemon #16 /vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(116): IlluminateQueueConsoleWorkCommand::runWorker #15 /vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(100): IlluminateQueueConsoleWorkCommand::handle #14 /vendor/laravel/horizon/src/Console/WorkCommand.php(51): LaravelHorizonConsoleWorkCommand::handle #13 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): IlluminateContainerBoundMethod::IlluminateContainer{closure} #12 /vendor/laravel/framework/src/Illuminate/Container/Util.php(40): IlluminateContainerUtil::unwrapIfClosure #11 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): IlluminateContainerBoundMethod::callBoundMethod #10 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): IlluminateContainerBoundMethod::call #9 /vendor/laravel/framework/src/Illuminate/Container/Container.php(610): IlluminateContainerContainer::call #8 /vendor/laravel/framework/src/Illuminate/Console/Command.php(136): IlluminateConsoleCommand::execute #7 /vendor/symfony/console/Command/Command.php(298): SymfonyComponentConsoleCommandCommand::run #6 /vendor/laravel/framework/src/Illuminate/Console/Command.php(121): IlluminateConsoleCommand::run #5 /vendor/symfony/console/Application.php(1015): SymfonyComponentConsoleApplication::doRunCommand #4 /vendor/symfony/console/Application.php(299): SymfonyComponentConsoleApplication::doRun #3 /vendor/symfony/console/Application.php(171): SymfonyComponentConsoleApplication::run #2 /vendor/laravel/framework/src/Illuminate/Console/Application.php(93): IlluminateConsoleApplication::run #1 /vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): IlluminateFoundationConsoleKernel::handle #0 /artisan(37): null

The error comes from the following file, line 33, which isdispatch(...):

hasFile('file')) { return false; } # default // return in_array(strtolower($request->method()), ['post', 'put', 'patch', 'delete']); # firehose return true; } public function logRequest(Request $request) { if (config('feature.logAllHttpRequests')) { $log = []; $log['method'] = $request->getMethod(); $log['url'] = $request->getPathInfo(); $log['headers'] = json_encode($request->headers->all()); $log['body'] = json_encode($request->except(config('http-logger.except'))); dispatch(function () use ($log) { $newLog = new HttpLog; $newLog->url = $log['url']; $newLog->method = $log['method']; $newLog->headers = $log['headers']; $newLog->body = $log['body']; $newLog->created_at = now(); $newLog->save(); }); } } }

What do you think I did wrong?

Laravel version: 9.11.0 PHP version: 8.0.18

P粉790819727
P粉790819727

reply all (1)
P粉803527801

Clearing cache and restarting Horizon works.

php artisan optimization: clear

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!