Skip to content

[4.x]: Change in ElementQuery::count effecting EVENT_BEFORE_PREPARE events #15001

@myleshyson

Description

@myleshyson

What happened?

Description

We noticed that after updating to Craft 4.9, one of our queries wasn't running properly. The logic for this particular query depends on the EntryQuery::EVENT_BEFORE_PREPARE event. In particular, in depended on the orderBy property to be null for for count queries to run properly.

Now however, because of this change, the orderBy property is not being nulled like it was before with yiii\db\Query::queryScaler method.

I'm not sure if this was on purpose? Either way would it be possible to either:
a) keep the queryScaler logic from yiii\db\Query::queryScaler for scalar queries (count, min, max, etc) so that things run like they did before the change OR
b) add a property to ElementQuery, something like queryMethod, so that events can add that logic back if the query is a scalar query?

Craft CMS version

Craft 4.9.0

PHP version

8.2

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions