When I enabled error reporting, I noticed Category.inc was throwing up a LOT of errors like this:
Notice: Undefined property: stdClass::$79 in /var/www/html/dbptest/modules/category/category.inc on line 1444
Looking at the code, it looks like this...
while ($item = db_fetch_object($result)) {
$cache[$type][$item->$id] = $item;
$i++;
}
Specifically the $cache[$type] line. Why is it referring to $item->$id (bearing in mind that $id seems to be the current node you're viewing). Should this line not be:
$cache[$type][$item->nid] = $item;
I change it to that on mine and the errors disappeared - whats the impact?
PS: I have made no patch - its a 4 byte change. Its not hard to do yourself :-)
Comments
Comment #1
nicholasthompsonCan anyone confirm this or at least tell me if I'm talking crap! :-) Cheers.
Comment #2
nicholasthompsonOk - I think I made a mistake, it should be cid not nid... I think!
Comment #3
bdragon commentedAgreed, the code is bogus.
Comment #4
bdragon commentedAlso, I think $cache[$type][$id] = $item; would be the intent.
Comment #5
nicholasthompsonI doubt it because $type and $id dont change in that loop. You'd end up setting the same variable to loads of different things repeatedly.
Maybe that whole function needs better remarks in it - I find some of it quite confusing, like what is $overflow_from for?
Comment #6
nicholasthompsonOk - I just did a clean install on a site and I'm coming up with wierd errors. Sometimes $item contains a number of properties (cid, cnid, description, weight, depth & title) and sometimes it contains only a nid.
It doesn't help that this function has next to no comments in it so i have no idea what that array is expecting. Does it need a cid or a nid?
Comment #7
bdragon commentedThe code is broken. Period. Commenting it out doesn't hurt anything.
Comment #8
bdragon commentedThis was sitting in my patch directory for a couple of weeks.
This patch was my attempt at optimizing the function. It's kind of ugly, but I think it works. (Havent touched it since Oct 4)
Comment #9
bdragon commentedChanging title.
Comment #10
JirkaRybka commentedThis code survived the 5.x era (somehow - I don't really know whether this got really fixed and how), and was finally removed, early in the 5.x->6.x porting process. Later, it was replaced by a completely different approach at #501378: PERFORMANCE! Central caching for category API functions.
So, this issue is definitely obsolete, as it's about a bit of code that no longer exists in Category package. (4.7.x and 5.x versions are not supported now.)