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 146 forks source link

Cakephp 4.4 breaks ApiListener #676

Closed asgraf closed 2 years ago

asgraf commented 2 years ago

In cakephp 4.4 $this->getRequest()->is('xml') always returns true, even for regular html requests (tested on latest Firefox). This break ApiListener because $this->getRequest()->is('api') is now always true and this causes it to throw Method Not Allowed exception for all GET requests

Probably bug in cakephp 4.4 it self

ADmad commented 2 years ago

Closing as the issue isn't directly related to this plugin.

sitedyno commented 2 years ago

Are the detectors defined by ApiListener needed? They are defined here: https://github.com/FriendsOfCake/crud/blob/ace4262d8c1c6d4b26937cb19f8d3b1b954aeb4b/src/Listener/ApiListener.php#L36-L38

Commenting out the following lines keeps ApiListener from overriding the CakePHP detectors and things work for me again: https://github.com/FriendsOfCake/crud/blob/ace4262d8c1c6d4b26937cb19f8d3b1b954aeb4b/src/Listener/ApiListener.php#L392-L394

ADmad commented 2 years ago

While the is(xml) and is(json) checks will continue working, without the overrides the custom is(api) check won't. So the overrides will have to be updated to include the new exclude key for XML as done in core.