FriendsOfCake / crud

Production-grade rapid controller development with built in love for API and Search

Home Page:https://crud.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Errors when visiting `/error` url

asgraf opened this issue · comments

Steps to reproduce:

  1. Create new cakephp application from cakephp/app
  2. Install Crud plugin
  3. Visit https://localhost/error (I assume you are working on a localhost domain)

You will get following errors:

notice: Undefined property: ErrorController::$Crud in /application/vendor/friendsofcake/crud/src/Controller/ControllerTrait.php on line 97
error: [TypeError] method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given in /application/vendor/friendsofcake/crud/src/Controller/ControllerTrait.php on line 97
commented

Either add a parent::initialize() call to your ErrorController::initialize() or include the ControllerTrait for the individual controllers instead of AppController.

From my experience adding parent::initialize() call in ErrorController::initialize() is bad idea because it can sometimes cause infinite error loops in some cases.
My project has 90+ controllers & tables. Manually adding ControllerTrait to each of them (except ErrorController) would be lot of work that could be avoided by simple if statements in ControllerTrait itself

commented

Add $this->dispatchComponents['Crud'] = false in your ErrorController::initialize().

It worked. I suggest adding this to installation manual.