UI > milestone > Bug (approved)

open tasks for milestone --> invalid project_id/#4078

Summary

v0.08
approved
Feb 16, 2007
100%
Feb 16, 2007 / guest
Jan 6, 2009 / phsouzacruz
pixtur
 

Attached files

No files uploaded
 
This task does not have any text yet.
Doubleclick here to add some.

Issue report

Minor
Have not tried
Apache/2.2.0 (Win200sp4) PHP/5.2.0
0.0792
2007-02-07
Project > Milestones > click on "Open Tasks" or "Closed Tasks" for a Milestone

result: Error "invalid project_id"

(reproducible on streber-pm.org too)
 

7 Comments

pixtur:Confirmed...

5 years ago

I will check this. Thanks for reporting.

guest:Also

5 years ago - Delete

This is something that I am looking into as well, I'll post if I find anything, but it may be a while as this is my most in-depth foray into the Streber internals so far.
Great software, by the way.

guest:Continued

5 years ago - Delete

I know that it's dying out in project_more.inc.php at line 557, but I don't know where this is getting called from.

pixtur:This was a really tricky bug...

5 years ago (2. update 5 years ago)

from list_milestones.inc.php line 296

     $buffer.= wiki2html($task->description, $task->project);

Here $task->project is 1908. After calling wiki2html()...

from render_wiki.inc.php line 1760

function &wiki2html(&$text, &$project=NULL, $item_id=NULL, $field_name=NULL)
{
...
    ### convert, if id is given ###
    if(!is_object($project)) {
        $project= Project::getVisibleById($project);
    }

$task->project is now the Project-Object! Although passing the parameter by reference might be a little bit too much optimization, I really think this is a weird behavior... This actually boils down to never ever pass parameters by reference, unless you are really sure what you are doing...

Changing the function definition to ...

  function &wiki2html(&$text, $project=NULL, $item_id=NULL, $field_name=NULL)

fixes the bug. I probably will revert all referenced parameters in all Streber code. Just found another reason why php sucks, although I am note sure I can blame it for this behavior. (But this bug would not have happened in python...)


guest:Why pass by reference...

5 years ago - visible as suggested - Delete

... anyway in PHP5? Objects are passed by reference anyway, and anything else should only be passed by reference if you actually want to change it along the way, which is something you should avoid in most cases. (It is much better practice to use return values for this.)

pixtur:Yeah...

5 years ago

... passing be reference is tricky. I though I could save the copying of the large memory blocks by just using the pointer. But I learned my lesson hopefully :)


buennagelj:No need to pass by reference...

5 years ago

... in PHP5.

Even in PHP4, passing references where only recommended for objects (and for those rare cases where you actually need side effects).

When passing by value (i.e. by copy) the Zend Engine doesn't physically copy the variable until you actually write to it. Until then, it uses a mechanism called reference counting, which was even improved with PHP5.

So you don't have to fear that PHP will use lots of memory if you pass large parameters by value. You're fine as long as you don't write to the passed variable.