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

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
adamsi

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

Post 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 :)
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm
Location: Finland

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

Post 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
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

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

Post 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!
Post Reply

Return to “Developers Discussion”