Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#2623 closed defect (fixed)

selectOutputFormat does not update correclt the php pointer to the current outputformat set in the map file

Reported by: assefa Owned by: mapserverbugs
Priority: normal Milestone: 5.2 release
Component: MapScript-PHP Version: unspecified
Severity: normal Keywords:
Cc:

Description (last modified by dmorissette)

Here is a scenario:

mapfile contains an imagetype and one outputformat

  IMAGETYPE png

  ...
  OUTPUTFORMAT
    NAME "mypdf"
    ...
  END  

php script

$map_file="f:/msapps/gmap_pdf/htdocs/gmap75.map";
$oMap = ms_newMapObj("$map_file");
$oMap->selectOutputFormat("mypdf");
$oMap->outputformat->setOption("aaa", 30);

This has the effect of modifying the "wrong" outputformat (in this case the outputformat defined as "png") instead of modifying the "mypdf" format.

Attachments (1)

bug2623.patch (2.5 KB ) - added by assefa 16 years ago.
patch for php_mapscript.c

Download all attachments as: .zip

Change History (7)

comment:1 by assefa, 16 years ago

The issue I think is that the php object still points to the original outputformat instead of the new outputformat set in the map.

Not sure what the best approach is to solve this but one way could be to add a map_handle in the object and use it to always select the current output object.

comment:2 by dmorissette, 16 years ago

Description: modified (diff)
Milestone: 5.2 release

The _map_handle_ approach could possibly work, but the handle of the PHP object at map->outputformat would be invalid (since it would still refer to the original outputFormatObj C struct).

Perhaps a cleaner fix would be to destroy the map->outputformat PHP object (which is a PHP wrapper with a ref to the C struct with a stub destructor that does nothing) and create a new one in php3_ms_map_selectOutputFormat() using _phpms_build_outputformat_object()? I don't think we do that kind of stuff anywhere yet, but this way the handle would be maintained properly.

by assefa, 16 years ago

Attachment: bug2623.patch added

patch for php_mapscript.c

comment:3 by assefa, 16 years ago

Attaching is the patch I want to apply. I am not sure if this is good enough (not losing memory) but solves the initial issue described in this bug.

comment:4 by assefa, 16 years ago

Resolution: fixed
Status: newclosed

committed patch (r7613)

comment:5 by dmorissette, 16 years ago

FYI I tested r7613 under Valgrind with a PHP script that changes the outputFormatObj multiple times and uses print_r to dump it and no leak or memory errors were reported, and according to print_r the object is updated properly every time.

There might still be leaks that are caught by the PHP garbage collector before Valgrind sees them, but at least I can confirm that there are no persistent leaks or corruption of underlying MapServer C structs.

comment:6 by assefa, 16 years ago

Thanks for doing the tests.

Note: See TracTickets for help on using tickets.