| Project: | Advertisement |
| Version: | 6.x-2.2 |
| Component: | ad_channel module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Problem/Motivation
In ad_channel.inc, the function ad_channel_cache_filter() attempts to filter a given set of ads. Toward the end of the function, the "premiere" status of the ads are checked, and if they are in fact premiere ads, they are returned while other ads are not.
However, if no ads are denoted as premiere, a single channel of one of original given ads is selected at random, and the ads for this particular channel are returned.
The returned ads from ad_channel_cache_filter() may be later sent to ad_weight_probability_cache_filter() which applies the probability for the given ads.
If in the circumstance that there are (A) multiple channels with 1 active ad per channel, (B) none of these ads are "premiere," and (C) a probability other than 1 is set for any of the ads, the effect of the probability will not be observed. This is because, as denoted above, only 1 of the channel's ads are sent to the probability filter (and therefore, 1 ad is sent to the probability filter). In order to correctly observe probability, all of the ads must be marked as premiere so that they are all sent to the probability filter.
This could very well be "by design" but I retain some doubt.
Here's the code in question, the last few lines being the alleged culprit.
<?php
$premiere = adserve_cache('get_cache', 'premiere');
if (is_array($premiere)) {
$premieres = array();
foreach (array_keys($valid_ads) as $chid) {
foreach ($valid_ads[$chid] as $aid) {
if (in_array($aid, $premiere)) {
_debug_echo("ad_channel_cache: aid($aid) is premiere advertisement");
$premieres[$aid] = $aid;
}
else {
_debug_echo("ad_channel_cache: aid($aid) is not a premiere advertisement");
}
}
}
if (!empty($premieres)) {
_debug_echo("ad_channel_cache: returning premiere advertisements");
return $premieres;
}
}
_debug_echo("ad_channel_cache: returning non-premiere advertisements from randomly selected channel $random_channel");
if (isset($valid_ads[$random_channel])) {
return ad_channel_enforce_inventory_level($random_channel, $valid_ads[$random_channel]);
}
?>Proposed resolution
If in fact there are no premiere ads, it seems that instead of selecting a channel at random, all ads from all applicable channels should be returned.
Remaining tasks
Determine if the random channel practice is best.
User interface changes
None.
API changes
None.