FUDApi - fetch categories [message #161924] |
Sun, 21 February 2010 03:56 |
jlundan
Messages: 4 Registered: February 2010 Location: Finland
Karma: 0
|
Junior Member |
|
|
Hi,
If assume correctly, the fud_fetch_cat_forums should return all forums inside given categories.
However, the function uses another FUDApi function called _fud_simple_fetch_query. This function is defined as:
function _fud_simple_fetch_query($arg, $query)
{
if ($arg) {
$arg = is_numeric($arg) ? array($arg) : $arg;
} else {
$arg = array();
}
$result = array();
$r = uq(str_replace('{ARG}', implode(',', $arg), $query));
while ($row = db_rowobj($r)) {
$result[] = $row;
}
unset($r);
if ($arg && count($result) != count($arg)) {
return FALSE;
} else {
if (count($result) == 1) {
return array_pop($result);
} else {
return $result;
}
}
}
after unset($r); statement the code compares count of arguments into count of results. If the count of arguments does not match count of results the function returns false. This, as far as I understand, means that if I pass single category id into the function, I will get proper result if the category has only one forum inside of it. If the category has two forums or more, I get false.
I think this is a bug, or have I misunderstood something?
|
|
|
|
Re: FUDApi - fetch categories [message #161929 is a reply to message #161925] |
Sun, 21 February 2010 09:08 |
jlundan
Messages: 4 Registered: February 2010 Location: Finland
Karma: 0
|
Junior Member |
|
|
The code
if ($arg && count($result) != count($arg)) {
return FALSE;
just beneath unset($r) says
"if $arg evaluates true and result count does not equal arg count return false"
lets assume that I have two forums inside category which id is 1. The category id (1) goes to $arg variable. My result contains two rows since I have two forums inside my category. My $arg exists, my arg count is one and my result count is two. The function returns FALSE since both conditions in the if match.
Am I just missing something? =)
|
|
|