- Issue created by @skyriter
- πΊπΈUnited States skyriter
Another option would be to have
getNidsOfType()
accept a prefix argument, which could be the<bundle_type>
or anything else. - Merge request !7Removes duplicate prefix when calling getNidsOfType β (Merged) created by skyriter
- πΊπΈUnited States swirt Florida
Interesting. I think the source of the problem is that the caller of gatherItemsToProcess() is getItemsToProcess() and it stringifies the keys, and in your case, calling getNidsOfType() to feed gatherItemsToProcess() also calls stringify, so it is getting double stringified, which is not the intent.
The simplest change would be to remove the call to stringify from getNidsOfType(). That makes things right by not double stringifying everything.
I do like the more meaningful prefix though, but unfortunately there is no way to customize that in getItemsToProcess() so that everything could have good meaningful prefixes... unless we added a new method getTypeOfThingOperatedOn() to the BatchScriptInterface interface. Doing that would make it a required method that would need to be defined in all scripts. getTypeOfThingOperatedOn() would just need to return a string, like "facility_health_service", or xyz_paragraph or whatever the key happened to represent.
I don't think we want it to be baked into getNidsOfType() like you are proposing for a few reasons:
- It is an expansion of concerns of the function. It is only supposed to get the nids, it does not always mean those nids are going to be the things operated on. Yes I may load all the nids, but what I am actually operating on are the terms that are used on all those nids, or paragraphs that are referenced (anything related to the nid, but not the nid itself.
- Similar to above, it makes it the function more opinionated than it should be.
- It is relying on double stringification, which I think we should not be doing.
Recommended path:
- Remove the call to stringify from getNidsOfType()
- Add a method getTypeOfThingOperatedOn() that returns a string, to the BatchScriptInterface
- Add examples of uising getTypeOfThingOperatedOn() to the following"
- /src/cbo_scripts/TestDo10Things.php
- /src/cbo_scripts/TestDo10ThingsWithError.php
- /StarterScript.php.text
- Status changed to Fixed
7 months ago 2:59pm 15 April 2024 - πΊπΈUnited States swirt Florida
This is fantastic and simple. Thank you so much for finding and fixing.
- Status changed to Fixed
7 months ago 4:52pm 15 April 2024 - πΊπΈUnited States skyriter