#99451PHPDoc, name of arguments and documentation not very intuitive for ExpressionBuilder::inSet
Description
Problems
1. The order is reversed: the values in ->inSet which are passed to FIND_IN_SET are reversed
2. argument names do not clearly reflect what is needle, what is haystack, what is the comma separated list
3. PHPDoc is vague, possibly also misleading:
> $fieldName The field name.
> string $value Argument to be used in FIND_IN_SET() comparison.
4. Possibly it might be good ideat to rename the function name (or create a new one and deprecate the old) as it is not a simple FIND_IN_SET, it is a FIND_IN_SET where the haystack refers to a database field name which contains a comma separated list of values
Suggestions
To mitigate this, I think at least the following should be done:
- function argument names should be named in a way which makes it intuitive. For example, use names such as “needle” and “haystack” or “pattern” and “fieldList” as is customary in PHP and / or SQL.
- make PHPDoc more specific if helpful in addition to argument names. Remove explanations which only repeat the name of the argumen. E.g. “field name” as explanation for fieldName is unnecessary fluff.
- possibly improve documentation: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Database/ExpressionBuilder/Index.html#comparisons. Apply same principles here.
Reviews 2
Related issues 1
History 810
-
Sybille Peters changed Related to #83074 <span data-processor="relativetime" data-value="2023-01-03T16:21:15+00:00" > 01/03/23, 16:21 </span>
-
Sybille Peters changed tracker
FeatureTask TYPO3 Version 11 <span data-processor="relativetime" data-value="2023-01-03T17:35:51+00:00" > 01/03/23, 17:35 </span> -
Sybille Peters commented <span data-processor="relativetime" data-value="2023-01-04T12:21:15+00:00" > 01/04/23, 12:21 </span>
-
Sybille Peters changed description <span data-processor="relativetime" data-value="2023-01-04T12:25:40+00:00" > 01/04/23, 12:25 </span>
-
Sybille Peters changed description <span data-processor="relativetime" data-value="2023-01-04T12:26:12+00:00" > 01/04/23, 12:26 </span>
-
Garvin Hicking changed Sprint Focus On Location Sprint <span data-processor="relativetime" data-value="2026-08-06T16:26:41+00:00" > 08/06/26, 16:26 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 96434 status
NewUnder Review <span data-processor="relativetime" data-value="2026-10-06T20:43:36+00:00" > 10/06/26, 20:43 </span> -
Gerrit Code Review pushed patch set 1 for 14.3 to change 96492 <span data-processor="relativetime" data-value="2026-10-07T16:29:16+00:00" > 10/07/26, 16:29 </span>
-
Georg Ringer commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-10-07T16:35:09+00:00" > 10/07/26, 16:35 </span>Applied in changeset commit:bc486c87769aee693488085ef038976e9f3b818b.
-
Sybille Peters commented <span data-processor="relativetime" data-value="2026-10-07T17:01:10+00:00" > 10/07/26, 17:01 </span>
Thank you Georg!
See explanation by Alexander Opitz:
https://forge.typo3.org/issues/83074#note-4
> As Morton already wrote, you are using the function wrong.
> The two parameters of inSet which you are using inSet(string $fieldName, string $value, …) are defined:
> $fieldName … The name of the field, which contains a comma separated string/set which will be searched for.
> $value … The element which is searched inside this set (This string SHOULD NOT contain commas).
> As you are using a NamedParameter you do not get an exception while calling the inSet method as the NamedParameter can’t be quantified at that moment.
> You should use the in() method which is defined as:
> $fieldName The field to search in
> $value … The comma separated string/set( or array which will be imploded) for which will be searched inside the given field.