在 Laravel 6 v6.20.43、Laravel Telescope v2.1.17 中, /vendor/laravel/telescope/src/Watchers/EventWatcher.php:91,报错:get_class() expects parameter 1 to be object, string given

1、在 /vendor/laravel/telescope/src/Watchers/EventWatcher.php:91,报错:get_class() expects parameter 1 to be object, string given。如图1

在 /vendor/laravel/telescope/src/Watchers/EventWatcher.php:91,报错:get_class() expects parameter 1 to be object, string given。

图1

{
    "message": "get_class() expects parameter 1 to be object, string given",
    "status_code": 500,
    "debug": {
        "line": 91,
        "file": "E://wwwroot//wshop-master//platform//vendor//laravel//telescope//src//Watchers//EventWatcher.php",
        "class": "ErrorException",
        "trace": [
            "#0 [internal function]: Illuminate//Foundation//Bootstrap//HandleExceptions->handleError(2, 'get_class() exp...', 'E:////wwwroot////wsho...', 91, Array)",
            "#1 E://wwwroot//wshop-master//platform//vendor//laravel//telescope//src//Watchers//EventWatcher.php(91): get_class('App////Listeners////U...')",
            "#2 [internal function]: Laravel//Telescope//Watchers//EventWatcher->Laravel//Telescope//Watchers//{closure}(Array, 1)",
            "#3 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Support//Collection.php(638): array_map(Object(Closure), Array, Array)",
            "#4 E://wwwroot//wshop-master//platform//vendor//laravel//telescope//src//Watchers//EventWatcher.php(95): Illuminate//Support//Collection->map(Object(Closure))",
            "#5 E://wwwroot//wshop-master//platform//vendor//laravel//telescope//src//Watchers//EventWatcher.php(47): Laravel//Telescope//Watchers//EventWatcher->formatListeners('App////Events////Them...')",
            "#6 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Events//Dispatcher.php(366): Laravel//Telescope//Watchers//EventWatcher->recordEvent('App////Events////Them...', Array)",
            "#7 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Events//Dispatcher.php(218): Illuminate//Events//Dispatcher->Illuminate//Events//{closure}('App////Events////Them...', Array)",
            "#8 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Foundation//helpers.php(477): Illuminate//Events//Dispatcher->dispatch('App////Events////Them...')",
            "#9 E://wwwroot//wshop-master//platform//app//Services//ThemeService.php(124): event(Object(App//Events//Theme//ThemeUpdated))",
            "#10 E://wwwroot//wshop-master//platform//app//Services//ThemeService.php(184): App//Services//ThemeService->update(2, Array, false)",
            "#11 E://wwwroot//wshop-master//platform//app//Http//Controllers//Admin//API//ThemeController.php(50): App//Services//ThemeService->setDefault(2)",
            "#12 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Routing//Controller.php(54): App//Http//Controllers//Admin//API//ThemeController->setDefault('2', Object(App//Services//ThemeService))",
            "#13 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Routing//ControllerDispatcher.php(45): Illuminate//Routing//Controller->callAction('setDefault', Array)",
            "#14 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Routing//Route.php(219): Illuminate//Routing//ControllerDispatcher->dispatch(Object(Illuminate//Routing//Route), Object(App//Http//Controllers//Admin//API//ThemeController), 'setDefault')",
            "#15 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Routing//Route.php(176): Illuminate//Routing//Route->runController()",
            "#16 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Routing//Router.php(681): Illuminate//Routing//Route->run()",
            "#17 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(130): Illuminate//Routing//Router->Illuminate//Routing//{closure}(Object(Dingo//Api//Http//Request))",
            "#18 E://wwwroot//wshop-master//platform//vendor//spatie//laravel-permission//src//Middlewares//RoleOrPermissionMiddleware.php(25): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#19 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(171): Spatie//Permission//Middlewares//RoleOrPermissionMiddleware->handle(Object(Dingo//Api//Http//Request), Object(Closure), 'manage_themes|a...')",
            "#20 E://wwwroot//wshop-master//platform//app//Http//Middleware//CheckStoreAdminStatus.php(45): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#21 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(171): App//Http//Middleware//CheckStoreAdminStatus->handle(Object(Dingo//Api//Http//Request), Object(Closure))",
            "#22 E://wwwroot//wshop-master//platform//app//Http//Middleware//SwitchLanguage.php(28): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#23 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(171): App//Http//Middleware//SwitchLanguage->handle(Object(Dingo//Api//Http//Request), Object(Closure))",
            "#24 E://wwwroot//wshop-master//platform//vendor//dingo//api//src//Http//Middleware//Auth.php(55): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#25 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(171): Dingo//Api//Http//Middleware//Auth->handle(Object(Dingo//Api//Http//Request), Object(Closure))",
            "#26 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Auth//Middleware//Authenticate.php(43): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#27 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(171): Illuminate//Auth//Middleware//Authenticate->handle(Object(Dingo//Api//Http//Request), Object(Closure), 'api')",
            "#28 E://wwwroot//wshop-master//platform//vendor//dingo//api//src//Http//Middleware//PrepareController.php(45): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#29 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(171): Dingo//Api//Http//Middleware//PrepareController->handle(Object(Dingo//Api//Http//Request), Object(Closure))",
            "#30 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(105): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#31 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Routing//Router.php(683): Illuminate//Pipeline//Pipeline->then(Object(Closure))",
            "#32 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Routing//Router.php(658): Illuminate//Routing//Router->runRouteWithinStack(Object(Illuminate//Routing//Route), Object(Dingo//Api//Http//Request))",
            "#33 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Routing//Router.php(624): Illuminate//Routing//Router->runRoute(Object(Dingo//Api//Http//Request), Object(Illuminate//Routing//Route))",
            "#34 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Routing//Router.php(613): Illuminate//Routing//Router->dispatchToRoute(Object(Dingo//Api//Http//Request))",
            "#35 E://wwwroot//wshop-master//platform//vendor//dingo//api//src//Routing//Adapter//Laravel.php(88): Illuminate//Routing//Router->dispatch(Object(Dingo//Api//Http//Request))",
            "#36 E://wwwroot//wshop-master//platform//vendor//dingo//api//src//Routing//Router.php(518): Dingo//Api//Routing//Adapter//Laravel->dispatch(Object(Dingo//Api//Http//Request), 'v1')",
            "#37 E://wwwroot//wshop-master//platform//vendor//dingo//api//src//Http//Middleware//Request.php(126): Dingo//Api//Routing//Router->dispatch(Object(Dingo//Api//Http//Request))",
            "#38 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(130): Dingo//Api//Http//Middleware//Request->Dingo//Api//Http//Middleware//{closure}(Object(Dingo//Api//Http//Request))",
            "#39 E://wwwroot//wshop-master//platform//app//Http//Middleware//ChangeAppUrlMiddleware.php(23): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#40 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(171): App//Http//Middleware//ChangeAppUrlMiddleware->handle(Object(Dingo//Api//Http//Request), Object(Closure))",
            "#41 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Foundation//Http//Middleware//TransformsRequest.php(21): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#42 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(171): Illuminate//Foundation//Http//Middleware//TransformsRequest->handle(Object(Dingo//Api//Http//Request), Object(Closure))",
            "#43 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Foundation//Http//Middleware//TransformsRequest.php(21): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#44 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(171): Illuminate//Foundation//Http//Middleware//TransformsRequest->handle(Object(Dingo//Api//Http//Request), Object(Closure))",
            "#45 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Foundation//Http//Middleware//ValidatePostSize.php(27): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#46 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(171): Illuminate//Foundation//Http//Middleware//ValidatePostSize->handle(Object(Dingo//Api//Http//Request), Object(Closure))",
            "#47 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Foundation//Http//Middleware//CheckForMaintenanceMode.php(63): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#48 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(171): Illuminate//Foundation//Http//Middleware//CheckForMaintenanceMode->handle(Object(Dingo//Api//Http//Request), Object(Closure))",
            "#49 E://wwwroot//wshop-master//platform//vendor//fideloper//proxy//src//TrustProxies.php(57): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#50 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(171): Fideloper//Proxy//TrustProxies->handle(Object(Dingo//Api//Http//Request), Object(Closure))",
            "#51 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(105): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Dingo//Api//Http//Request))",
            "#52 E://wwwroot//wshop-master//platform//vendor//dingo//api//src//Http//Middleware//Request.php(127): Illuminate//Pipeline//Pipeline->then(Object(Closure))",
            "#53 E://wwwroot//wshop-master//platform//vendor//dingo//api//src//Http//Middleware//Request.php(103): Dingo//Api//Http//Middleware//Request->sendRequestThroughRouter(Object(Dingo//Api//Http//Request))",
            "#54 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(171): Dingo//Api//Http//Middleware//Request->handle(Object(Dingo//Api//Http//Request), Object(Closure))",
            "#55 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Pipeline//Pipeline.php(105): Illuminate//Pipeline//Pipeline->Illuminate//Pipeline//{closure}(Object(Illuminate//Http//Request))",
            "#56 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Foundation//Http//Kernel.php(145): Illuminate//Pipeline//Pipeline->then(Object(Closure))",
            "#57 E://wwwroot//wshop-master//platform//vendor//laravel//framework//src//Illuminate//Foundation//Http//Kernel.php(110): Illuminate//Foundation//Http//Kernel->sendRequestThroughRouter(Object(Illuminate//Http//Request))",
            "#58 E://wwwroot//wshop-master//platform//public//index.php(57): Illuminate//Foundation//Http//Kernel->handle(Object(Illuminate//Http//Request))",
            "#59 {main}"
        ]
    }
}

2、查看 /vendor/laravel/telescope/src/Watchers/EventWatcher.php:91

                if (is_string($listener)) {
                    return Str::contains($listener, '@') ? $listener : $listener.'@handle';
                } elseif (is_array($listener)) {
                    return get_class($listener[0]).'@'.$listener[1];
                }

3、查看 EventServiceProvider

    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [

        ThemeUpdated::class                                  => [
            ThemeUpdatedWebhookListener::class
        ],

    ];

4、这看起来像一个 Bug,我看到有一个新的提交正好解决了这个问题。提交:https://github.com/laravel/telescope/commit/a69fc6f4f5fd5b0ac5a242981e162774cbb69e17 。support new listeners syntax。如图2

这看起来像一个 Bug,我看到有一个新的提交正好解决了这个问题。提交:https://github.com/laravel/telescope/commit/a69fc6f4f5fd5b0ac5a242981e162774cbb69e17 。support new listeners syntax。

图2

5、我暂未升级,而是参考提交的变更,编辑 /vendor/laravel/telescope/src/Watchers/EventWatcher.php

                if (is_string($listener)) {
                    return Str::contains($listener, '@') ? $listener : $listener.'@handle';
                } elseif (is_array($listener) && is_string($listener[0])) {
                    return $listener[0].'@'.$listener[1];
                } elseif (is_array($listener) && is_object($listener[0])) {
                    return get_class($listener[0]).'@'.$listener[1];
                }

6、再次运行程序,不再报错。后续决定升级 Laravel Telescope 至包含这个提交的版本。

 

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/webdev/250734.html

(0)
上一篇 2022年5月1日 03:51
下一篇 2022年5月1日 03:55

相关推荐

发表回复

登录后才能评论