Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Fix EloquentQueryBuilder orderby bug #10023

Merged
merged 1 commit into from May 9, 2024

Conversation

duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented May 9, 2024

This pull request fixes an issue with the recently introduced EloquentQueryBuilder@enforceOrderBy method, where it was trying to access the query property on the Eloquent query builder instance.

However, that property is protected so it errored so couldn't be accessed by the __get method inside Eloquent.

Stack trace:

Exception: Property [query] does not exist on the Eloquent builder instance.

/home/runner/work/eloquent-driver/eloquent-driver/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1943
/home/runner/work/eloquent-driver/eloquent-driver/vendor/statamic/cms/src/Query/EloquentQueryBuilder.php:514
/home/runner/work/eloquent-driver/eloquent-driver/vendor/statamic/cms/src/Query/EloquentQueryBuilder.php:488
/home/runner/work/eloquent-driver/eloquent-driver/vendor/statamic/cms/src/Search/Searchables/Entries.php:34
/home/runner/work/eloquent-driver/eloquent-driver/vendor/statamic/cms/src/Search/Searchables.php:51

This PR fixes that issue by calling the getQuery method on the builder instead of calling the query property directly.

Caused by #9956.

@jasonvarga jasonvarga merged commit 9b56c76 into 4.x May 9, 2024
39 checks passed
@jasonvarga jasonvarga deleted the fix/eloquent-query-builder-orderby-bug branch May 9, 2024 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants