Opened 23 years ago
Closed 23 years ago
#23 closed defect (fixed)
PHP MapScript ms_newMapObj() with empty map doesn't work
Reported by: | dmorissette | Owned by: | dmorissette |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | MapScript-PHP | Version: | 3.5 |
Severity: | normal | Keywords: | |
Cc: |
Description
Problem reported by Rob Martinson on 2001-07-02: I'm attempting to load layers from a database on an empty map object. This way I can control all of the maps from a database without writing out a new .map file for each change. Currently I'm trying: dl("php_mapscript.so"); $map = ms_newMapObj(''); $map->set("width",400); $map->set("height",300); $map->set("shapepath","/path/to/my/data"); $layer = ms_newLayerObj($map); $layer->set("name","county"); $layer->set("type",POLYGON); $layer->set("status",MS_ON); $layer->set("data","ctybdpy"); $img = $map->draw(); <--at this point I get an error stating "Object has an invalid _handle_ property" The same small script and data work if I load the layers through a .map file using the same paths with: dl("php_mapscript.so"); $map = ms_newMapObj("demo2.map"); $img = $map->draw(); I'm sure someone else has done something similar. Any pointers?
Change History (6)
comment:2 by , 23 years ago
Another confirmation of this and to expand on my earlier problem about using dynamic maps... I am unable to add any new layer to any new or existing map via PHP/Mapscript. In short, if I create a layer using $layer = ms_newlayerobj($mapObj); on a map object using a new or existing map, no matter the number of or lack of properties and/or classes I set for the layer, the next call to ANY sub object, property, or method of the mapobject fails with "Object has an invalid _handle_ property. This has been listed in the MapServer bugs database by Daniel Morissette, but I thought I would expand on the problem here. Rob Martinson
comment:3 by , 23 years ago
From Vladimir G.: My system configuration is: SUSE linux 6.4. Mapserver version: 3.4 PHP version: 4.06 Apache version: 1.3.12 The mapserver configure command is: ./configure --with-gd=/root/Desktop/programas/gd-1.8.4/ --with-php=/root/Desktop/programas/php-4.0.6 --with-apxs --with-sde --with-jpeg --with-ttf The php configure command is: ./configure --with-dbase=yes --with-system-regex --with-jpeg-dir=/root/Desktop/programas/jpeg-6b --with-png-dir=/root/Desktop/programas/libpng/ --with-swf=yes --with-pgsql=/usr/lib/pgsql --with-mysql=yes --with-gd=yes --with-zlib=yes --with-xml --with-yp --with-ftp --with-snmp --with-config-file-path=/etc/httpd --with-apxs=/usr/sbin/apxs --with-exec-dir=/usr/lib/apache/bin --enable-versioning --enable-track-vars --enable-magic-quotes --enable-safe-mode --enable-sysvsem --enable-sysvshm --enable-thread-safety i386-suse-linux-gnu
comment:4 by , 23 years ago
Status: | new → assigned, assefa@dmsolutions.ca |
---|
comment:5 by , 23 years ago
From Rob Martinson: Thank you thank you! Consider this a confirmation to problems with PHP 4.0.6. I backtracked and rebuilt with source from 4.0.5 and I have zero problems! The issues with losing the handle of the map when dynamically generating a map from database contents are gone. I can now reliably (it seems) create a map on a blank .map file using mapscript only to set map/layer/class properties and add additional layers. This works now with the CVS version of Mapserver, Gdal and PHP 4.0.5 on my end.
comment:6 by , 23 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
The problem was that we have resource member vars (the _handle_ property), but we didn't increment the refcount on the resource that we were referring to. So the resource referred to was getting deleted even if some objects were still referring to it. The fix was to add a zend_list_addref(res_id) everytime we set a resource member variable in an object. The reason why the problem happens only with PHP4.0.6 is that when a resource member variable in an object is deleted in PHP4.0.6 the list destructor is called but *it was not* in previous version of PHP, which resulted in memory leaks before. Things seem to be working fine now with PHP 4.0.6 and with previous versions (but we may be leaking memory with 4.0.5 and older versions though).
Note:
See TracTickets
for help on using tickets.