FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Bug Reports » FUDApi - fetch categories (fud_fetch_cat_forums behavior)
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
FUDApi - fetch categories [message #161924] Sun, 21 February 2010 03:56 Go to next message
jlundan is currently offline  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 #161925 is a reply to message #161924] Sun, 21 February 2010 08:18 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
It looks OK to me. If the function returns one result, it will be returned to the caller. However, if it returns more than one result, an array will be returned to the caller.
Re: FUDApi - fetch categories [message #161929 is a reply to message #161925] Sun, 21 February 2010 09:08 Go to previous message
jlundan is currently offline  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? =)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Problem with FUDforum API global variables
Next Topic: Prefix on answers
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 10:50:14 GMT 2024

Total time taken to generate the page: 0.02483 seconds