Error with CakePHP: Uncaught RuntimeException: You cannot call all() on a non-select query. Use execute() instead.
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 337
- Forks
- 116
- Avg merge
- 17d 2h
- Merged PRs (30d)
- 1
Description
I'm using the latest rollbar version (2.0.0). Rollbar has started throwing this exception recently. I could not find the relevant method from the stack trace.
Looks like Rollbar is trying the serialize the Query object involved in the exception (to include in the payload) and fails.
2020-05-31 20:30:03 Error: [Cake\Error\FatalErrorException] Uncaught RuntimeException: You cannot call all() on a non-select query. Use execute() instead. in /var/www/src/vendor/cakephp/cakephp/src/ORM/Query.php:1041
Stack trace:
#0 /var/www/src/vendor/cakephp/cakephp/src/Datasource/QueryTrait.php(141): Cake\ORM\Query->all()
#1 /var/www/src/vendor/rollbar/rollbar/src/Utilities.php(102): Cake\ORM\Query->getIterator()
#2 /var/www/src/vendor/rollbar/rollbar/src/Utilities.php(159): Rollbar\Utilities::serializeForRollbar(Object(Cake\ORM\Query), NULL, Array, -1, 2)
#3 /var/www/src/vendor/rollbar/rollbar/src/Utilities.php(105): Rollbar\Utilities::serializeObject(Object(Cake\ORM\Query), NULL, Array, -1, 1)
#4 /var/www/src/vendor/rollbar/rollbar/src/Utilities.php(117): Rollbar\Utilities::serializeForRollbar(Array, NULL, Array, -1, 1)
#5 /var/www/src/vendor/rollbar/rollbar/src/Payload/Frame.php(111): Rollbar\Utilities::serializeForRollbar(Array, NULL, Array)
#6 in /var/www/src/vendor/cakephp/cakephp/src/ORM/Query.php on line 1041
Stack Trace:
- /var/www/dev/src/Error/RollbarErrorHandlerTrait.php:50
- /var/www/dev/vendor/cakephp/cakephp/src/Error/BaseErrorHandler.php:122
- [main] - [internal], line ??
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in vendor/rollbar/rollbar/src/Utilities.php at the serialization paths shown in the stack trace, especially lines 102 and 159, and reproduce the failure with a Cake\ORM\Query non-select query. Done means serializing the query for the Rollbar payload no longer raises the CakePHP all() exception; no test file is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100