Skip to content

Laravel Telescope incompatibility #185

New issue

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

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

Already on GitHub? # to your account

Closed
zannix opened this issue Nov 15, 2018 · 5 comments
Closed

Laravel Telescope incompatibility #185

zannix opened this issue Nov 15, 2018 · 5 comments
Assignees

Comments

@zannix
Copy link

zannix commented Nov 15, 2018

Upon installing Laravel Telescope package, there seems to be an issue that's being caused by the incompatibility with laravel-model-caching.

The issue is also commented here: laravel/telescope#187

ErrorException thrown with message "Undefined offset: 0" in
/vendor/laravel/telescope/src/Watchers/ModelWatcher.php:35

When laravel-model-caching is disabled, everything operates normally.

@mikebronner
Copy link
Owner

@zannix Thanks for reporting! Can you provide your complete stack trace for this error, as well as the eloquent query you are are running. I will try to reproduce. Better yet, if you have a public repo that already reproduces this issue, please link it here so I can investigate. :) Thanks!

@zannix
Copy link
Author

zannix commented Nov 15, 2018

The issue was caused upon trying to instantiate and save a new model inside a static method of the model class by calling $model = new self(); .... $model->save();

Here is the full stack trace:

#60 ErrorException in /vendor/laravel/telescope/src/Watchers/ModelWatcher.php:35
#59 Illuminate\Foundation\Bootstrap\HandleExceptions:handleError in /vendor/laravel/telescope/src/Watchers/ModelWatcher.php:35
#58 Laravel\Telescope\Watchers\ModelWatcher:recordAction in /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:357
#57 Illuminate\Events\Dispatcher:Illuminate\Events{closure} in /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:209
#56 Illuminate\Events\Dispatcher:dispatch in /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:182
#55 Illuminate\Events\Dispatcher:fire in /vendor/fico7489/laravel-pivot/src/Traits/ExtendFireModelEventTrait.php:37
#54 App\Contract:fireModelEvent in /vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:807
#53 Illuminate\Database\Eloquent\Model:performInsert in /vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:649
#52 Illuminate\Database\Eloquent\Model:save in /app/Contract.php:90
#51 App\Contract:create in /app/Http/Controllers/ContractController.php:17
#50 App\Http\Controllers\ContractController:create in /vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
#49 call_user_func_array in /vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
#48 Illuminate\Routing\Controller:callAction in /vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45
#47 Illuminate\Routing\ControllerDispatcher:dispatch in /vendor/laravel/framework/src/Illuminate/Routing/Route.php:212
#46 Illuminate\Routing\Route:runController in /vendor/laravel/framework/src/Illuminate/Routing/Route.php:169
#45 Illuminate\Routing\Route:run in /vendor/laravel/framework/src/Illuminate/Routing/Router.php:679
#44 Illuminate\Routing\Router:Illuminate\Routing{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
#43 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41
#42 Illuminate\Routing\Middleware\SubstituteBindings:handle in /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#41 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#40 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:75
#39 Illuminate\Foundation\Http\Middleware\VerifyCsrfToken:handle in /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#38 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#37 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php:49
#36 Illuminate\View\Middleware\ShareErrorsFromSession:handle in /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#35 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#34 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:63
#33 Illuminate\Session\Middleware\StartSession:handle in /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#32 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#31 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37
#30 Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse:handle in /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#29 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#28 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:66
#27 Illuminate\Cookie\Middleware\EncryptCookies:handle in /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#26 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#25 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
#24 Illuminate\Pipeline\Pipeline:then in /vendor/laravel/framework/src/Illuminate/Routing/Router.php:681
#23 Illuminate\Routing\Router:runRouteWithinStack in /vendor/laravel/framework/src/Illuminate/Routing/Router.php:656
#22 Illuminate\Routing\Router:runRoute in /vendor/laravel/framework/src/Illuminate/Routing/Router.php:622
#21 Illuminate\Routing\Router:dispatchToRoute in /vendor/laravel/framework/src/Illuminate/Routing/Router.php:611
#20 Illuminate\Routing\Router:dispatch in /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:176
#19 Illuminate\Foundation\Http\Kernel:Illuminate\Foundation\Http{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
#18 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /vendor/fideloper/proxy/src/TrustProxies.php:57
#17 Fideloper\Proxy\TrustProxies:handle in /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#16 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#15 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:31
#14 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#13 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#12 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:31
#11 Illuminate\Foundation\Http\Middleware\TransformsRequest:handle in /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#10 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#9 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27
#8 Illuminate\Foundation\Http\Middleware\ValidatePostSize:handle in /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#7 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#6 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:62
#5 Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode:handle in /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151
#4 Illuminate\Pipeline\Pipeline:Illuminate\Pipeline{closure} in /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
#3 Illuminate\Routing\Pipeline:Illuminate\Routing{closure} in /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
#2 Illuminate\Pipeline\Pipeline:then in /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:151
#1 Illuminate\Foundation\Http\Kernel:sendRequestThroughRouter in /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
#0 Illuminate\Foundation\Http\Kernel:handle in /public/index.php:55

@mikebronner
Copy link
Owner

This is likely an issue with the laravel-pivot package, as model-caching does not fire events. See the following discussions:
laravel/telescope#187
fico7489/laravel-pivot#50

I believe this should be resolved once laravel-pivot 4.0 is released (no date on that though).

mikebronner added a commit that referenced this issue Nov 30, 2018
@pthurmond
Copy link

pthurmond commented Mar 4, 2019

I'm going to throw my 2 cents in here. There is some kind of interaction that is happening between this plugin and that one that triggers these kinds of errors.

I say that because I am in the process of trying to add your auto-caching to my, relatively new, repo. When I make the call to my API endpoint without implementing model caching it returns just fine as is. HOWEVER, as soon as I add the Cacheable trait from this plugin it barfs with the following output.

Call to undefined method Illuminate\Events\Dispatcher::fire()

I'm doing this through Postman, pardon the broken error listing. It refers to this file "var/www/vendor/fico7489/laravel-pivot/src/Traits/ExtendFireModelEventTrait.php" on line 36

It also outputs this code segment:
`
if (!isset(static::$dispatcher)) {
return true;
}

    // First, we will get the proper method to call on the event dispatcher, and then we
    // will attempt to fire a custom, object based event for the given event. If that
    // returns a result we can return that result, or we'll call the string events.
    $method = $halt ? 'until' : 'fire';

    $result = $this->filterModelEventResults(
        $this->fireCustomModelEvent($event, $method)
    );

    if (false === $result) {
        return false;
    }

    $payload = ['model' => $this, 'relation' => $relationName, 'pivotIds' => $ids, 'pivotIdsAttributes' => $idsAttributes];

    return !empty($result) ? $result : static::$dispatcher->{$method}(
        "eloquent.{$event}: ".static::class, $payload
    );
}

}
`

This is on my local env running via Docksal. I upgraded to Laravel 5.8. Got v0.4.7 of this package, etc.

Somehow these two do not play nicely together. I will report back when I find more out.

@mikebronner
Copy link
Owner

@pthurmond Please see this issue: #219

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants