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

"taxArray" does not work correctly if an empty array or null is passed to "terms" with "operator" IN #39

Open
relaxdd opened this issue Feb 20, 2025 · 3 comments

Comments

@relaxdd
Copy link

relaxdd commented Feb 20, 2025

It is assumed that if we pass a null or an empty array, then the tax query should not work in principle, but in this case it works and returns nothing, so it should not be, given that I cannot dynamically change the graphql query based on the number of elements in the array, so I would have to hack it. invert the query and base it on the "exclude" field


Предполагается что если мы передаем null или пустой массив то tax query не должен отрабатывать в принципе, но в этом случае он отрабатывает и ничего не возвращает, так не должно быть учитывая что я никак не могу динамически менять graphql запрос основываясь на кол-ве элементов в массиве, по этому что бы исправить это мне придется инвертировать запрос и основываться на поле "exclude"


Версия WPGraphQL: 2.0.0
Версия WPGraphQL Tax Query: 0.2.0

Image

@relaxdd
Copy link
Author

relaxdd commented Feb 20, 2025

I forgot to clarify that if you don't pass the $categories argument, the same thing happens.

@relaxdd
Copy link
Author

relaxdd commented Feb 20, 2025

Полазив в коде плагина я с удивлением обнаружил что в нём нет никакой проверки на то что "terms" может быть массивом и как то очищать/удалять его, есть ощущение что плагин не дописан до конца, или идея была в том что каждый сам по себя будет дорабатывать основываясь на фундаменте плагина?


After poking around in the plugin code, I was surprised to find that there is no check in it that "terms" can be an array and somehow clean/delete it, there is a feeling that the plugin is not fully written, or the idea was that everyone would refine themselves based on the foundation of the plugin?

@relaxdd
Copy link
Author

relaxdd commented Feb 20, 2025

А ведь достаточно было обернуть код на строке ~291

$tax_query[ $tax_array_key ] = $value;

На это

if ( ! empty( $value['terms'] ) ) {
    $tax_query[ $tax_array_key ] = $value;
}	

И все, это что разве так сложно?

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

No branches or pull requests

1 participant