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

EntryQuery::typeId() does not accept array syntax with not anymore #6754

Closed
Anubarak opened this issue Aug 31, 2020 · 4 comments
Closed

EntryQuery::typeId() does not accept array syntax with not anymore #6754

Anubarak opened this issue Aug 31, 2020 · 4 comments
Labels

Comments

@Anubarak
Copy link
Contributor

Anubarak commented Aug 31, 2020

Description

After Updating to Craft 3.5 the typeId syntax stated in the PHPDoc via ['not', 1, 2]
https://github.com/craftcms/cms/blob/develop/src/elements/db/EntryQuery.php#L417
does not work anymore, cause not is not a string in _normalizeTypeId https://github.com/craftcms/cms/blob/develop/src/elements/db/EntryQuery.php#L921

Steps to reproduce

  1. Run Entry::find()->typeId(['not', 1, 2])->all();
  2. see an exception yii\base\InvalidConfigException: Invalid typeId param value because is_numeric('not') returns false

Additional info

  • Craft version: 3.5.x
@Anubarak Anubarak added the bug label Aug 31, 2020
@Anubarak Anubarak changed the title EntryQuery::typeId() docs are deprecated EntryQuery::typeId() does not accept array syntax with not anymore Aug 31, 2020
@brandonkelly
Copy link
Member

Whoops, sorry about that. Fixed for the next release.

@Anubarak
Copy link
Contributor Author

Anubarak commented Sep 1, 2020

Thank you. But what's the point of querying for the correct ids again? My whole point in passing ids instead of the handle is to reduce the amount of queries.
If you keep it like that I wouldn't use the not syntax anymore but add a custom and where to achieve the same functionality as before

@brandonkelly
Copy link
Member

brandonkelly commented Sep 1, 2020

In 3.5 we need to know the exact entry type IDs (if specified) so we can register them as cache invalidation tags, if a cache is actively being created:

if ($this->typeId) {
foreach ($this->typeId as $typeId) {
$tags[] = "entryType:$typeId";
}

That way if the query is surrounded by {% cache %} tags or used within a GraphQL query, the cache will only be cleared when an entry with the exact same type is saved/deleted, rather than any entry in the same section.

@brandonkelly
Copy link
Member

Craft 3.5.8 is out now with that fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants