FriendsOfCake / crud

Production-grade rapid controller development with built in love for API and Search
https://crud.readthedocs.io/en/latest/
MIT License
375 stars 145 forks source link

Call to `isActionMapped` during `Controller.initialize` event crashes controller bake #688

Open asgraf opened 1 year ago

asgraf commented 1 year ago

How to reproduce:

1) For example add following line at the end of your AppController::initialize()

debug($this->Crud->isActionMapped());

2) Bake any controller (confirm that you want to override controller if already exists) 3) Crash during bake:

[TypeError] Cake\Utility\Inflector::variable(): Argument #1 ($string) must be of type string, null given, called in /application/vendor/friendsofcake/crud/src/Controller/Component/CrudComponent.php on line 430 in /application/vendor/cakephp/cakephp/src/Utility/Inflector.php on line 511
ADmad commented 1 year ago

The default crud action is set in CrudComponent::initialize() which gets run after Controller::initialize(). While we could fix the exception calling isActionMapped() so early without an argument will never yield the correct result.