_simpleads_load_ads mishandles single/multi value $tid argument

Created on 26 January 2016, over 8 years ago
Updated 9 June 2023, about 1 year ago

Hello,
I have really been enjoying incorporating this module into a project I am working on. I found what seems to be a minor "bug" in the way that _simpleads_load_ads() is handling the $tid argument, though it may be relatively minor.

What I am doing:
I'm trying to dynamically load ads by ad group, sometimes multiple ad groups, for displaying among other content.

What I find:
It seems to me that if a single integer is passed as $tid to _simpleads_load_ads(), then the ad group sort settings are correctly found by _simpleads_adgroup_settings(). If an array of term ids is passed as $tid ( presumably to load ads from more than one group at once ), then the sort order is ignored and ads are randomized. This makes sense due to the possibility of conflicting sort orders.

The Issue:
The behavior of _simpleads_load_ads() will differ if it is passed a single integer as $tid , or if a single tid is provided as the only element of an array.

$ads = _simpleads_load_ads(123);
// ads are sorted by the ad group's settings

$ads = _simpleads_load_ads(array(123));
// ad sort order is ignored and 'random' is used

If I'm looping through a list of ad groups and the list is only 1 item long, I could accidentally pass a single-value array rather than an integer and it would be very confusing to figure out why my sort settings were not being respected.

I'm not sure if this qualifies as enough of an issue, but it seems like a simple fix. I also understand that I possibly should not call an internal 'helper' method directly, but hey, you know people are going to find it. If there is a more correct way that I've missed please let me know.

Thanks again for the great module.

πŸ› Bug report
Status

Closed: won't fix

Version

1.9

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States Anthony Robertson

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024