craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.22k stars 626 forks source link

[4.8.4]: Calling unknown method: craft\web\Response::getIsRevision() #14635

Closed croxton closed 5 months ago

croxton commented 6 months ago

What happened?

Description

Error thrown when saving an entry and returning to the entry listing screen (I think).

Steps to reproduce

I didn't notice any errors reported in the control panel, but happened to spot the error in the log a few seconds after editing an entry.

2024-03-20 12:09:14 [web.ERROR] [yii\base\UnknownMethodException] Calling unknown method: craft\web\Response::getIsRevision()
#0 [/var/www/html/vendor/craftcms/cms/src/controllers/ElementsController.php(1790):](https://github.com/craftcms/cms/tree/4.8.4/src/controllers/ElementsController.php#L1790) yii\base\Component->__call('getIsRevision', Array)
#1 [internal function]: craft\controllers\ElementsController->actionRecentActivity()
#2 [/var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57):](https://github.com/yiisoft/yii2/tree/2.0.48.1/framework/base/InlineAction.php#L57) call_user_func_array(Array, Array)
#3 [/var/www/html/vendor/yiisoft/yii2/base/Controller.php(178):](https://github.com/yiisoft/yii2/tree/2.0.48.1/framework/base/Controller.php#L178) yii\base\InlineAction->runWithParams(Array)
#4 [/var/www/html/vendor/yiisoft/yii2/base/Module.php(552):](https://github.com/yiisoft/yii2/tree/2.0.48.1/framework/base/Module.php#L552) yii\base\Controller->runAction('recent-activity', Array)
#5 [/var/www/html/vendor/craftcms/cms/src/web/Application.php(341):](https://github.com/craftcms/cms/tree/4.8.4/src/web/Application.php#L341) yii\base\Module->runAction('elements/recent...', Array)
#6 [/var/www/html/vendor/craftcms/cms/src/web/Application.php(642):](https://github.com/craftcms/cms/tree/4.8.4/src/web/Application.php#L642) craft\web\Application->runAction('elements/recent...', Array)
#7 [/var/www/html/vendor/craftcms/cms/src/web/Application.php(303):](https://github.com/craftcms/cms/tree/4.8.4/src/web/Application.php#L303) craft\web\Application->_processActionRequest(Object(craft\web\Request))
#8 [/var/www/html/vendor/yiisoft/yii2/base/Application.php(384):](https://github.com/yiisoft/yii2/tree/2.0.48.1/framework/base/Application.php#L384) craft\web\Application->handleRequest(Object(craft\web\Request))
#9 /var/www/html/web/index.php(12): yii\base\Application->run()
#10 {main}

The bug is happening here: https://github.com/craftcms/cms/blob/9d218d94f490e787e1c9f20ed9d2bd909a3bdfd2/src/controllers/ElementsController.php#L1790

Response from here: https://github.com/craftcms/cms/blob/9d218d94f490e787e1c9f20ed9d2bd909a3bdfd2/src/controllers/ElementsController.php#L1937

So it's missing a check in the controller to see if the response from _element() is a web responses, and if it is, return it directly. (This is according to mattgrayisok)

Craft CMS version

4.8.4

PHP version

8.1

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

No response

i-just commented 5 months ago

Hi, thanks for reporting! I was able to replicate this (though not consistently). I raised a PR for this.

For future reference, to replicate this (not consistently), I did the following:

brandonkelly commented 5 months ago

Just released Craft 4.8.5 and 5.0.0-beta.11 with the fix for this. Thanks again!

charliegrinsted commented 1 month ago

hey @brandonkelly

We're seeing a similar thing when the elements/save-draft action is run, presumably when it tries to autosave? The site is running 4.10.5.

I'm not entirely sure how to reproduce it but I imagine it's similar to the convoluted aforementioned steps, as this is a multi site install with many editors.


2024-07-30 15:58:39 [web.ERROR] [yii\\base\\UnknownMethodException] Calling unknown method: craft\\web\\Response::getIsRevision()",
"#0 /var/www/html/vendor/craftcms/cms/src/controllers/ElementsController.php(1342): yii\\base\\Component->__call('getIsRevision', Array)",
"#1 [internal function]: craft\\controllers\\ElementsController->actionSaveDraft()",
"#2 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)",
"#3 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\\base\\InlineAction->runWithParams(Array)",
"#4 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\\base\\Controller->runAction('save-draft', Array)",
"#5 /var/www/html/vendor/craftcms/cms/src/web/Application.php(340): yii\\base\\Module->runAction('elements/save-d...', Array)",
"#6 /var/www/html/vendor/craftcms/cms/src/web/Application.php(641): craft\\web\\Application->runAction('elements/save-d...', Array)",
"#7 /var/www/html/vendor/craftcms/cms/src/web/Application.php(302): craft\\web\\Application->_processActionRequest(Object(craft\\web\\Request))",
"#8 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\\web\\Application->handleRequest(Object(craft\\web\\Request))",
"#9 /var/www/html/public/index.php(12): yii\\base\\Application->run()",
"#10 {main}"
brandonkelly commented 1 month ago

@charliegrinsted That should be fixed now for the next release.

To get the fix early, change your craftcms/cms requirement in composer.json to:

"craftcms/cms": "4.x-dev as 4.10.7",

and then run composer update.

brandonkelly commented 1 month ago

Craft 4.10.8 is out with that fix. Thanks for reporting, @charliegrinsted!

jonleverrier commented 3 days ago

@brandonkelly @i-just I've started to see regular occurrences of this error message since updating Craft recently. Here's the stack trace (apologies for the formatting):

Calling unknown method: craft\web\Response::getIsRevision() {"trace":["#0 /home/removed/releases/0bec64af89ec999cee1d453404970c8c80c15d47/craft/vendor/craftcms/cms/src/controllers/ElementsController.php(1675): yii\\base\\Component->__call()","#1 [internal function]: craft\\controllers\\ElementsController->actionUpdateFieldLayout()","#2 /home/removed/releases/0bec64af89ec999cee1d453404970c8c80c15d47/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()","#3 /home/removed/releases/0bec64af89ec999cee1d453404970c8c80c15d47/craft/vendor/yiisoft/yii2/base/Controller.php(178): yii\\base\\InlineAction->runWithParams()","#4 /home/removed/releases/0bec64af89ec999cee1d453404970c8c80c15d47/craft/vendor/yiisoft/yii2/base/Module.php(552): yii\\base\\Controller->runAction()","#5 /home/removed/releases/0bec64af89ec999cee1d453404970c8c80c15d47/craft/vendor/craftcms/cms/src/web/Application.php(340): yii\\base\\Module->runAction()","#6 /home/removed/releases/0bec64af89ec999cee1d453404970c8c80c15d47/craft/vendor/craftcms/cms/src/web/Application.php(639): craft\\web\\Application->runAction()","#7 /home/removed/releases/0bec64af89ec999cee1d453404970c8c80c15d47/craft/vendor/craftcms/cms/src/web/Application.php(302): craft\\web\\Application->_processActionRequest()","#8 /home/removed/releases/0bec64af89ec999cee1d453404970c8c80c15d47/craft/vendor/yiisoft/yii2/base/Application.php(384): craft\\web\\Application->handleRequest()","#9 /home/removed/releases/0bec64af89ec999cee1d453404970c8c80c15d47/public/index.php(12): yii\\base\\Application->run()","#10 {main}"],"memory":5153328,"exception":"[object] (yii\\base\\UnknownMethodException(code: 0): Calling unknown method: craft\\web\\Response::getIsRevision() at /home/removed/releases/0bec64af89ec999cee1d453404970c8c80c15d47/craft/vendor/yiisoft/yii2/base/Component.php:308)"} 

I'm running 4.12.2. Should I open a new ticket?

i-just commented 3 days ago

@jonleverrier - thanks for the stack trace. I raised a PR for this.

brandonkelly commented 2 days ago

@jonleverrier Craft 4.12.3 and 5.4.4 are out with that fix.