Bug tracker
post update not working as it should (fix completed in vcs)
Comments / History
The scenario is the following:
delete_topics is called with auto_sync = true
delete_topics calls delete_posts to delete all posts in the topics with $auto_sync=false
delete_posts then calls delete_topics with $auto_sync=false to delete the now empty topics
The original call to delete_topics resumes, but finds that there are no topics to delete and returns without running auto sync.
Personally, I'd say this call-structure is too complex and should be simplified.
The basic fix is to ensure that delete_topics isn't called recursively (there should be no need to do so - delete_topics already knows which topics to delete):
functions_admin.php
- Code: Select all
// Remove topics now having no posts?
if (sizeof($topic_ids))
{
$sql = 'SELECT topic_id
FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
GROUP BY topic_id';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$remove_topics[] = $row['topic_id'];
}
$db->sql_freeresult($result);
// Actually, those not within remove_topics should be removed. ;)
$remove_topics = array_diff($topic_ids, $remove_topics);
}
to
- Code: Select all
// Remove topics now having no posts?
if (sizeof($topic_ids) && $where_type !== 'topic_id')
{
$sql = 'SELECT topic_id
FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_ids) . '
GROUP BY topic_id';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$remove_topics[] = $row['topic_id'];
}
$db->sql_freeresult($result);
// Actually, those not within remove_topics should be removed. ;)
$remove_topics = array_diff($topic_ids, $remove_topics);
}
and
- Code: Select all
// We actually remove topics now to not be inconsistent (the delete_topics function calls this function too)
if (sizeof($remove_topics))
{
delete_topics('topic_id', $remove_topics, $auto_sync, $post_count_sync);
}
to
- Code: Select all
// We actually remove topics now to not be inconsistent (the delete_topics function calls this function too)
if (sizeof($remove_topics) && $where_type !== 'topic_id')
{
delete_topics('topic_id', $remove_topics, $auto_sync, $post_count_sync);
}
We may revisit this mechanism in 3.2.x. Rewrites or bigger changes are now forbidden within the 3.0.x source code (at least until gold) to make sure we have a stable code base.
Much better would be a way in PHP itself to check the functions state - as if it was a recursive object.