#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 )
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)
Change History (7)
comment:2 by , 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.
comment:3 by , 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:5 by , 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.