area17 / twill

Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/cnWk7EFv8R.
https://twillcms.com
Apache License 2.0
3.75k stars 572 forks source link

The exception handler is overriden if calling $model->getFullUrl() on the frontend #2607

Open Tofandel opened 3 months ago

Tofandel commented 3 months ago

The method getFullUrl has an unexpected side effect, because it constructs the controller of the model which binds a different exception handler even if the request doesn't originate from twill

This is problematic as then exceptions are not rendering as expected or reported to sentry

https://github.com/area17/twill/blob/6d022399eb8ab1d76aaea3e49d76fece54d62cc1/src/Models/Model.php#L185-L197 https://github.com/area17/twill/blob/6d022399eb8ab1d76aaea3e49d76fece54d62cc1/src/Http/Controllers/Admin/Controller.php#L20-L25

(And yes I spent 3 hours trying to figure out why my 404 pages were rendering like this in production image instead of with my custom view, long story short I have a menu that uses a Page model and gets the url of those pages using getFullUrl)