Topic: Bug: viewtopic.php generating nested `mysql_unbuffered_query` calls

When the cache/cache_ranks.php file does not exist, and a call to viewtopic.php is made, then the first time it calls get_title(), it will call generate_ranks_cache() which generates its own query with $unbuffered=true. viewtopic.php's query to fetch the actual posts also uses $unbuffered=true. This is a problem -- as the docs say, "You also have to fetch all result rows from an unbuffered SQL query, before you can send a new SQL query to MySQL." Indeed, when this is the case, the generate_ranks_cache() query interferes with viewtopic.php's query, and thus only the first post on the page is shown (because its $result handle is invalidated, so the while loop ends).

I solved this by adding

if (!defined('PUN_RANKS_LOADED'))
{
    require_once PUN_ROOT.'include/cache.php';
    generate_ranks_cache();
}

above "($hook = get_hook('vt_qr_get_posts')) ? eval($hook) : null;" in viewtopic.php. But that seems a bit inelegant; besides, perhaps things like this happen elsewhere, and a more general fix is needed? I don't know. You should probably look into it.

Re: Bug: viewtopic.php generating nested `mysql_unbuffered_query` calls

Ooh, very nice find smile

Re: Bug: viewtopic.php generating nested `mysql_unbuffered_query` calls

Bump. It doesn't look like this has been fixed yet, has it?

Re: Bug: viewtopic.php generating nested `mysql_unbuffered_query` calls

Correct. We're discussing the best way to deal with this (which includes figuring out if unbuffered queries actually give us a performance gain).