Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Mapscript support for PHP 5.4 #4309

Closed
jmckenna opened this issue May 8, 2012 · 9 comments
Closed

PHP Mapscript support for PHP 5.4 #4309

jmckenna opened this issue May 8, 2012 · 9 comments

Comments

@jmckenna
Copy link
Member

jmckenna commented May 8, 2012

  • we can use this ticket to monitor changes to PHP/MapScript for PHP 5.4 support
  • Trying to compile on Windows, I get a lot of errors with the "'zend_hash_copy'" function
  • From Googling, I came across this page describing possible changes needed to mapscript: http://web.archiveorange.com/archive/v/X3yUU6NbEA8EimcDw7e5
  • indeed many users suggest using 'if PHP_VERSION_ID < 50399' to handle the changes in our scripts
@jmckenna
Copy link
Member Author

jmckenna commented May 8, 2012

  • for the record, here are my errors with PHP 5.4.2 on Windows (MSVC 2008)
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(350) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(350) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(350) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(357) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(357) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(357) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(364) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(364) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(364) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(371) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(371) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(371) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(377) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(377) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_hash.h(377) : warning C4127: conditio
nal expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_operators.h(694) : warning C4127: con
ditional expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_operators.h(718) : warning C4127: con
ditional expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_operators.h(749) : warning C4127: con
ditional expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_execute.h(67) : warning C4127: condit
ional expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_execute.h(222) : warning C4127: condi
tional expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_execute.h(250) : warning C4127: condi
tional expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_execute.h(265) : warning C4127: condi
tional expression is constant
d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend_execute.h(293) : warning C4127: condi
tional expression is constant
D:\build\mapserver-buildkit-2008\php-5.4.2\tsrm\tsrm_win32.h(102) : warning C4115: 'utimbu
f' : named type definition in parentheses
d:\build\mapserver-buildkit-2008\mapserver-unicolet\mapserver.h(115) : warning C4005: 'vsn
printf' : macro redefinition
        d:\build\mapserver-buildkit-2008\php-5.4.2\main\snprintf.h(112) : see previous def
inition of 'vsnprintf'
d:\build\mapserver-buildkit-2008\gdal_1_9_0\port\cpl_config.h(20) : warning C4005: 'snprin
tf' : macro redefinition
        d:\build\mapserver-buildkit-2008\php-5.4.2\main\snprintf.h(107) : see previous def
inition of 'snprintf'
d:\build\mapserver-buildkit-2008\mapserver-unicolet\mapserver.h(2022) : warning C4028: for
mal parameter 3 different from declaration
d:\build\mapserver-buildkit-2008\mapserver-unicolet\mapserver.h(2022) : warning C4273: 'st
rnicmp' : inconsistent dll linkage
        C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\string.h(217) : see previo
us definition of 'strnicmp'
d:\build\mapserver-buildkit-2008\mapserver-unicolet\mapserver.h(2026) : warning C4273: 'st
ricmp' : inconsistent dll linkage
        C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\string.h(215) : see previo
us definition of 'stricmp'
d:\build\mapserver-buildkit-2008\mapserver-unicolet\mapserver.h(2030) : warning C4273: 'ph
p_strlcat' : inconsistent dll linkage
        D:\build\mapserver-buildkit-2008\php-5.4.2\main\php.h(133) : see previous definiti
on of 'php_strlcat'
d:\build\mapserver-buildkit-2008\mapserver-unicolet\mapserver.h(2034) : warning C4273: 'ph
p_strlcpy' : inconsistent dll linkage
        D:\build\mapserver-buildkit-2008\php-5.4.2\main\php.h(125) : see previous definiti
on of 'php_strlcpy'
php_mapscript_util.c(45) : error C2039: 'default_properties' : is not a member of '_zend_c
lass_entry'
        d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend.h(462) : see declaration of '
_zend_class_entry'
php_mapscript_util.c(45) : warning C4047: 'function' : 'HashTable *' differs in levels of
indirection from 'copy_ctor_func_t'
php_mapscript_util.c(45) : warning C4024: 'zend_hash_copy' : different types for formal an
d actual parameter 2
php_mapscript_util.c(45) : warning C4152: nonstandard extension, function/data pointer con
version in expression
php_mapscript_util.c(45) : warning C4022: 'zend_hash_copy' : pointer mismatch for actual p
arameter 4
php_mapscript_util.c(45) : error C2198: 'zend_hash_copy' : too few arguments for call
php_mapscript_util.c(46) : warning C4055: 'type cast' : from data pointer 'void *' to func
tion pointer 'zend_objects_free_object_storage_t'
php_mapscript_util.c(62) : error C2039: 'default_properties' : is not a member of '_zend_c
lass_entry'
        d:\build\mapserver-buildkit-2008\php-5.4.2\zend\zend.h(462) : see declaration of '
_zend_class_entry'
php_mapscript_util.c(62) : warning C4047: 'function' : 'HashTable *' differs in levels of
indirection from 'copy_ctor_func_t'
php_mapscript_util.c(62) : warning C4024: 'zend_hash_copy' : different types for formal an
d actual parameter 2
php_mapscript_util.c(62) : warning C4152: nonstandard extension, function/data pointer con
version in expression
php_mapscript_util.c(62) : warning C4022: 'zend_hash_copy' : pointer mismatch for actual p
arameter 4
php_mapscript_util.c(62) : error C2198: 'zend_hash_copy' : too few arguments for call
php_mapscript_util.c(63) : warning C4055: 'type cast' : from data pointer 'void *' to func
tion pointer 'zend_objects_free_object_storage_t'
php_mapscript_util.c(105) : warning C4127: conditional expression is constant
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.EXE"'
: return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\nmake.EXE
"' : return code '0x2'
Stop.

jmckenna added a commit that referenced this issue May 14, 2012
…es to Francesco Paolo Lovergine's debian php54 patches, which I was happy to discover (if he is not a MapServer committer we should give him privs ASAP..he tackled this back in March it appears). Tested with PHP 5.3.10 and PHP 5.4.3. Feedback, changes, tests, all welcome!
@jmckenna
Copy link
Member Author

Some background on the above changes:

@jmckenna
Copy link
Member Author

Because my text editor removed trailing spaces when saving (ARRRRRR!), I will paste the small changes I made here:

  • image.c
--- image-orig.c    Mon May 14 18:37:45 2012
+++ image.c Mon May 14 18:39:51 2012
@@ -303,10 +303,18 @@
     /* no filename - read stdout */

     /* if there is no output buffer active, set the header */
-    if (OG(ob_nesting_level)<=0)
-    {
-        php_header(TSRMLS_C);
-    }
+    //handle changes in PHP 5.4.x
+    #if PHP_VERSION_ID < 50399
+      if (OG(ob_nesting_level)<=0)
+      {
+          php_header(TSRMLS_C);
+      }
+    #else
+      if (php_output_get_level(TSRMLS_C)<=0)
+      {
+          php_header(TSRMLS_C);
+      }
+    #endif


     if (MS_RENDERER_PLUGIN(php_image->image->format))
  • php_mapscript.c
--- php_mapscript-orig.c    Mon May 14 18:37:40 2012
+++ php_mapscript.c Mon May 14 18:40:07 2012
@@ -899,7 +899,7 @@

 }

-function_entry mapscript_functions[] = {
+zend_function_entry mapscript_functions[] = {
     PHP_FE(ms_GetVersion, NULL)
     PHP_FE(ms_GetVersionInt,  NULL)
     PHP_FE(ms_newLineObj, NULL)
  • php_mapscript_util.c
--- php_mapscript_util-orig.c   Mon May 14 18:37:35 2012
+++ php_mapscript_util.c    Mon May 14 18:40:41 2012
@@ -42,7 +42,12 @@
     zobj->ce = ce;
     ALLOC_HASHTABLE(zobj->properties);
     zend_hash_init(zobj->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
-    zend_hash_copy(zobj->properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &temp, sizeof(zval *));
+    //handle changes in PHP 5.4.x
+    #if PHP_VERSION_ID < 50399
+      zend_hash_copy(zobj->properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &temp, sizeof(zval *));
+    #else
+      object_properties_init(zobj, ce);
+    #endif
     retval.handle = zend_objects_store_put(zobj, NULL, (zend_objects_free_object_storage_t)zend_objects_free_object, NULL TSRMLS_CC);
     retval.handlers = &mapscript_std_object_handlers;
     return retval;
@@ -59,7 +64,12 @@
     zobj->ce = ce;
     ALLOC_HASHTABLE(zobj->properties);
     zend_hash_init(zobj->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
-    zend_hash_copy(zobj->properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &temp, sizeof(zval *));
+    //handle changes in PHP 5.4.x
+    #if PHP_VERSION_ID < 50399
+      zend_hash_copy(zobj->properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &temp, sizeof(zval *));
+    #else
+      object_properties_init(zobj, ce);
+    #endif
     retval.handle = zend_objects_store_put(zobj, NULL, (zend_objects_free_object_storage_t)zend_objects_free_object, NULL TSRMLS_CC);
     retval.handlers = object_handlers;
     return retval;

@tbonfort
Copy link
Member

@jmckenna I think it's time for you to try out pull requests :)

@jmckenna
Copy link
Member Author

@tbonfort I agree, I will do so from now on.

@jmckenna
Copy link
Member Author

These changes have been available in MS4W for over a month now. No negative feedback. Closing issue!

@dmorissette
Copy link
Contributor

How'bout backporting to the 6.0 branch? I think that would be important in case we have another 6.0.x release

@jmckenna
Copy link
Member Author

@dmorissette excellent point. backported changes to branch-6-0.

@dmorissette
Copy link
Contributor

Thanks. For the record, the revision is 0d68cd5

minaco2 pushed a commit to git-portage/git-portage that referenced this issue Feb 5, 2015
…only one at a time) using patch from MapServer/MapServer#4309

(Portage version: 2.2.15/cvs/Linux x86_64, signed Manifest commit with key D1F781EFF9F4A3B6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants