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

BUG: missing int cast #1909

Open
simonschaufi opened this issue Jul 2, 2024 · 1 comment
Open

BUG: missing int cast #1909

simonschaufi opened this issue Jul 2, 2024 · 1 comment

Comments

@simonschaufi
Copy link

simonschaufi commented Jul 2, 2024

I have checked that the bug exists in the dev-development branch
Yes

I have checked that there are no already open issues or recently closed issues about this bug
Yes

Describe the bug
Missing int cast to compare uid with a potential string: https://github.com/FluidTYPO3/vhs/blob/development/Classes/ViewHelpers/Condition/Iterator/ContainsViewHelper.php#L132

To Reproduce
Steps to reproduce the behavior:

have this in a news template (needle is a string here!):

<v:condition.iterator.contains needle="{overwriteDemand.categories}" haystack="{newsItem.categories}">
	<f:then>yes</f:then>
	<f:else>no</f:else>
</v:condition.iterator.contains>

Expected behavior
output yes but always no.

cast to needle to int as uid is always an int but needle can be a string as well (coming from fluid template)

@NamelessCoder
Copy link
Member

Fix this quickly by casting: {overwriteDemand.categories as int}.

Side note: this condition would probably break or not work correctly; {overwriteDemand.categories} does not look like it would always contain a single value and needle must be a single value. If it works then that is by coincidence and you should extract/convert as needed to ensure it is always a single value, or use a different condition based on iterator.intersect to compare if iterators A and B have any elements in common.

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

2 participants