Repository navigation
Fix: query builder treats column names like date/time as callbacks - #353
Merged
Merged
Conversation
where(), orWhere(), if(), embed() and embedCount() used is_callable() to detect callbacks, which is also true for strings naming a PHP function. Columns such as date, time, key, max or file were invoked as functions, and if() would call a function named by a string value. Add Grammar::isCallback() so bare strings are never treated as callbacks; closures, invokable objects and array callables are unchanged.
Member
|
Thanks for this PR! We really appreciate your contribution. Our team will review it shortly. |
techmahedy
approved these changes
Oct 7, 2026
techmahedy
left a comment
Member
There was a problem hiding this comment.
Thanks @abdulmajidcse, great catch and a clear write-up. Treating strings as column names/values instead of callbacks is the right fix, and the tests for where/orWhere/if are solid. Merging this now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Description
where(),orWhere(),if(),embed()andembedCount()usedis_callable()to tell whether an argument is a callback.is_callable()also returns true for strings that name a PHP function, so ordinary column names and values were called as functions:where('date', $x)calleddate($builder)and threw aTypeError. Columns namedtime,key,max,min,file,endandrangefailed the same way, in bothEntity\BuilderandQuery\Builder.->if($request->input('filter'), …)withfilter=phpinforanphpinfo()and printed the server configuration.embed(['link', …])with a relation named after a function called that function as the relation's constraint.The fix adds a
Grammar::isCallback()helper (!is_string($value) && is_callable($value)) and uses it at these sites. Closures, invokable objects and[$obj, 'method']callables behave as before; only bare strings are no longer called.Checklist
tests/Builder/StringArgumentNotCallableTest.php: 20 tests that fail on the old code and pass on the new)