Skip to content

[4.x]: String resolution of type in EntryQuery doesnt appear to work correctly #18223

@jlawrence-yellostudio

Description

@jlawrence-yellostudio

What happened?

Description

The logic at the following line checks if the $item is an instance of EntryType:

return $item instanceof EntryType ? $item->id : null;

However the getEntryTypesByHandle method returns an array so it can never be true, resulting in typeId always being queried from the database:

$item = Craft::$app->getSections()->getEntryTypesByHandle($item);

Steps to reproduce

  1. Run the following code (two queries for the same type twice in succession).
$query = Entry::find();
Craft::configure($query, ['type' => 'myTypeHandle']);

$query = Entry::find();
Craft::configure($query, ['type' => 'myTypeHandle']);

Expected behavior

Type is resolved from Memoized array from the Sections service.

Actual behavior

Type is always queried from the database.

Craft CMS version

4.16.15

PHP version

8.3.22

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions