cerberos76 wrote:One side effect of this fix is that if Profile is not Standard, then the value of $countnews{$i} is wrong.
If an addon hooks in here:
# HOOK: BuildNews_ProfileType
and tries to use that same variable for some speed up or other tricks, it will be tricked in finding its value is wrong. ($countnews{$i} should return the number of news processed/built for that profile at any given time; it was put at the top of the build process to count all news...).
The increment of that counter with Parahead latest fix is done not for each news on each profile but only when that particular if gets called... which is only for standard profiles in crcore.pl (at the moment). This results in the counter being wrong for all other profiles
I will think to some cleaner solution, but as a temporary fix should work.
OK, I hear what you are saying and understand the goal...
I have some objections though, the thing is that having the counter at the "old" place in the begining of the loop counted *each* newsitem, not taking into considiration if it was being filtered out or not. For example if you had specified a "skip items" number in the profile the "file open test" would be throwned off and always appending.
It will also force every addon that does any filtering to decrement the counter in order for the file open test to work properly. No addon currently does this so any of them that would like to work with the 1.30-series must then be upgraded, like the Filter-by-Field addon. I don´t think that is a good approach considering the confusion it would mean of which addon version is working with which Coranto version... Scenarios like the one with the FbF-addon would be "common" and I could also see interesting bugs appearing when people start using old addons with the 1.30-series together with other updated addons that rely on the counter.
My humble suggestion is to keep it in the way it is after the fix I presented above and if an addon would like to use the "BuildNews_ProfileType"-hook and take advantage of this type of increment, they can do that very thing with a addonspecific increment.
BTW, I have made an addon called NewsCounter (found at my site) which basically does this counting thing *before* the actual building and stores the information in three different arrays, one for the total number of newsitems in a profile, one for the active number of news and one for how many news that has been archived. The problem with that addon is the same as here, it only works properly with a normal profile since an addon implementing another profile type can filter out items or just isn´t aware of how to deal with the counterarray...