Opened 20 years ago

Closed 20 years ago

Last modified 19 years ago

#718 closed defect (fixed)

Support for php 5

Reported by: mathieuparent@… Owned by: mapserverbugs
Priority: normal Milestone:
Component: MapScript-PHP Version: unspecified
Severity: normal Keywords: VERIFIED
Cc: pspencer@…, sylvain.pasche@…, gdallaire@…

Description

I can't compile mapserver with php 5.  
I think zend_* functions have changed.  
  
TODO :  
use the new zend_engine  
or wait swig on php 5

Attachments (1)

patch_php5.txt (11.1 KB ) - added by sylvain.pasche@… 20 years ago.
patch to compile php mapscript with php5

Download all attachments as: .zip

Change History (11)

comment:1 by dmorissette, 20 years ago

For the record, here is a copy of what I wrote to the mapserver-users list about
this:
----------

Some work will be required for sure to port php_mapscript.c to PHP5.

We know we'll have to do it at some point, but there is no formal plan yet on
how and when that will happen. PHP5 brings some very nice improvements in the
way objects are handled so it would be great for PHP MapScript apps to be able
to take advantage of that.

One possibility could be to just port what we have to PHP5, but some of the code
dates from PHP3 so it's becoming messy. Another option could be to try doing the
switch to SWIG, but some have reported that the SWIG-PHP module isn't actively
maintained so that may not be a viable option.

We'll see, but I wouldn't expect this to happen before the fall at a minimum
unless PHP5 becomes a priority for one of our paying clients.

by sylvain.pasche@…, 20 years ago

Attachment: patch_php5.txt added

patch to compile php mapscript with php5

comment:2 by sylvain.pasche@…, 20 years ago

Hello,

I tried to compile php mapscript with php 5, and hacked around to see
what was needed to get it compile, and in fact, the porting was not
too much pain :-).
I dont know the Zend API, but I greped php sources to find porting
examples. I did not test extensively the generated mapscript, but it
looks like to be able to generate an image out of a mapfile.

See the attached file for the patch.

Only two needed changes:

1) macros BYREF_FORCE|NONE have been replaced by BEGIN_ARG_INFO

+#ifdef ZEND_ENGINE_2
+ZEND_BEGIN_ARG_INFO(one_arg_force_ref, 0)
+    ZEND_ARG_PASS_INFO(1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(two_args_first_arg_force_ref, 0)
+    ZEND_ARG_PASS_INFO(1)
+    ZEND_ARG_PASS_INFO(0)
+ZEND_END_ARG_INFO()
+#else
 static unsigned char one_arg_force_ref[] = 
   { 1, BYREF_FORCE};
 static unsigned char two_args_first_arg_force_ref[] = 
     { 2, BYREF_FORCE, BYREF_NONE };
+#endif

2) some macros are needed to access zval properties.

 perl -pi -e 's/pObj->value.obj.properties/Z_OBJPROP_P(pObj)/g'
php_mapscript_util.c 
perl -pi -e 's/pThis->value.obj.properties/Z_OBJPROP_P(pThis)/g' php_mapscript.c 

I found these conversions in ./scripts/dev/conv_z_macros of the php
sources, and adapted a bit.

It compiles then with both php-4.3.8 and php-5.0.0.

comment:3 by dmorissette, 20 years ago

That's great news!  We'll have to give this a try when we have a minute!

comment:4 by gdallaire@…, 20 years ago

I'm testing this patch. It compiles. I will come back with more results.

comment:5 by gdallaire@…, 20 years ago

Tested OK with gmap-4.0 demo application. 
(http://www.maptools.org/dl/gmap-ms40.tar.gz)

Tested OK with Chameleon 1.99 beta 1 but Chameleon needs some adjustments to
work with php 5.0.

comment:6 by dmorissette, 20 years ago

Cc: spencer@… gdallaire@… added
Status: newassigned
Sounds great. I will try to apply the patch in CVS today.

comment:7 by dmorissette, 20 years ago

Resolution: fixed
Status: assignedclosed
The patch has been applied in both 4.3 (CVS) and the 4.2 branch (will be in
4.2.2). Thank you Sylvain for the patch!  :)

comment:8 by sylvain.pasche@…, 20 years ago

Cc: sylvain.pasche@… added
That's greats news, you're welcome.

Thanks all for the testing and the commit ;-)

comment:9 by gdallaire@…, 20 years ago

Keywords: VERIFIED added
Verified CVS version with both PHP v4.3.7 and v5.0.0 : OK

Verified branch-4-2 version with both PHP v4.3.7 and v5.0.0 : OK

I used gmap demo application.

comment:10 by mathieuparent@…, 19 years ago

dependson: 1100
Note: See TracTickets for help on using tickets.