PHP 5.2.17 Backports

If you handle support for a webhosting company you know that sometimes people need older versions of software, for example older shopping carts or zend optimizer. PHP 5.2.x many times is needed to run older software, but since it is not supported by PHP any more additional security patches are needed. There is a project http://code.google.com/p/php52-backports/ which has PHP 5.2. backports which I have been using. Recently I came across an error on compile.

/usr/src/redhat/BUILD/php-5.2.17/main/php_variables.c: In function ‘_php_import_environment_variables’:
/usr/src/redhat/BUILD/php-5.2.17/main/php_variables.c:457: error: too many arguments to function ‘zend_alter_ini_entry_ex’
/usr/src/redhat/BUILD/php-5.2.17/main/php_variables.c:479: error: too many arguments to function ‘zend_alter_ini_entry_ex’
/usr/src/redhat/BUILD/php-5.2.17/main/php_variables.c: In function ‘php_register_server_variables’:
/usr/src/redhat/BUILD/php-5.2.17/main/php_variables.c:605: error: too many arguments to function ‘zend_alter_ini_entry_ex’
/usr/src/redhat/BUILD/php-5.2.17/main/php_variables.c:632: error: too many arguments to function ‘zend_alter_ini_entry_ex’

To fix the error I have made the following patch:

--- main/php_variables.c.old    2012-08-02 21:06:35.000000000 +0400
+++ main/php_variables.c        2012-08-02 21:08:26.000000000 +0400
@@ -453,9 +453,7 @@
        /* turn off magic_quotes while importing environment variables */
        int magic_quotes_gpc = PG(magic_quotes_gpc);

-       if (magic_quotes_gpc) {
-               zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1 TSRMLS_CC);
-       }
+       PG(magic_quotes_gpc) = 0;

        for (env = environ; env != NULL && *env != NULL; env++) {
                p = strchr(*env, '=');
@@ -475,9 +473,7 @@
                efree(t);
        }

-       if (magic_quotes_gpc) {
-               zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "1", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1 TSRMLS_CC);
-       }
+       PG(magic_quotes_gpc) = magic_quotes_gpc;
 }

 zend_bool php_std_auto_global_callback(char *name, uint name_len TSRMLS_DC)
@@ -601,9 +597,7 @@
                zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_SERVER]);
        }
        PG(http_globals)[TRACK_VARS_SERVER] = array_ptr;
-       if (magic_quotes_gpc) {
-               zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1 TSRMLS_CC);
-       }
+       PG(magic_quotes_gpc) = 0;

        /* Server variables */
        if (sapi_module.register_server_variables) {
@@ -628,9 +622,7 @@
                php_register_variable_ex("REQUEST_TIME", &new_entry, array_ptr TSRMLS_CC);
        }

-       if (magic_quotes_gpc) {
-               zend_alter_ini_entry_ex("magic_quotes_gpc", sizeof("magic_quotes_gpc"), "1", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_ACTIVATE, 1 TSRMLS_CC);
-       }
+       PG(magic_quotes_gpc) = magic_quotes_gpc;
 }
 /* }}} */

This is applied after the security branch patch is applied.

RPM’s for the backports for centos 5.8 32 bit are at http://mirror.trouble-free.net/php-5.2.17/

The SRPM is at http://mirror.trouble-free.net/php-5.2.17/php-5.2.17-2.backports.src.rpm

Both are for 20120721 security branch patch (critical security bugfixes / FreeBSD port / stable).

Leave a Reply

Your email address will not be published. Required fields are marked *