Page 1 of 1

A possible bug in lib/classes/class.contentoperations.inc.php

Posted: Wed Sep 20, 2006 2:50 am
by adamsi
I installed 1.0.1 on an ubuntu-dapper server box, php version is 5.1.2 and mysql version is 5.0.21.

The problem is, when try to delete a content page, ajax timed out after 30 secs and report an error. After tracing the delete routine, I found that in lib/classes/class.contentoperations.inc.php line 440 a block of code may be incorrect, listed below:

    426                while ($current_parent_id > -1)
    427                {
    428                        $query = "SELECT item_order, parent_id, content_alias FROM ".cms_db_prefix()."content WHERE content_id = ?";
    429                        $row = &$db->GetRow($query, array($current_parent_id));
    430                        if ($row)
    431                        {
    432                                $current_hierarchy_position = str_pad($row['item_order'], 5, '0', STR_PAD_LEFT) . "." . $current_hierarchy_positi        on;
    433                                $current_id_hierarchy_position = $current_parent_id . '.' . $current_id_hierarchy_position;
    434                                $current_hierarchy_path = $row['content_alias'] . '/' . $current_hierarchy_path;
    435                                $current_parent_id = $row['parent_id'];
    436                                $count++;
    437                        }
    438                        else
    439                        {
    440                                $current_parent_id = 0;
    441                        }
    442                }

notice the line in red, when no rows retrieved, $current_parent_id is set to 0, and the whole loop may going forever since $current_parent_id will never be  less than -1. After changing line 440 to $current_parent_id = -1; , the problem is solved.

Is this a bug? Hope cmsms developers have a look at this.

and thank you for making such a great system, both coding and theme are beautiful :)

Re: A possible bug in lib/classes/class.contentoperations.inc.php

Posted: Wed Sep 20, 2006 9:04 am
by tsw
Yep, looks like a bug. hierarchy manager was changed quite a bit some time ago and it changed root node level from 1 to 0 :)


Thanks

Re: A possible bug in lib/classes/class.contentoperations.inc.php

Posted: Wed Sep 20, 2006 9:50 am
by Ted
Not sure why I haven't received an error from this, but it seems like the correct fix.  It'll be in 1.0.2 due out sometime later today.

Thanks!