logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Other Software View previous topic :: View next topic
Reply to topic   Topic: PHP 5.2 and PHP 5.3 apache2handler patch for 2.4
Author
NewEraCracker



Joined: 23 Aug 2010
Posts: 36

PostPosted: Fri 08 Jun '12 14:17    Post subject: PHP 5.2 and PHP 5.3 apache2handler patch for 2.4 Reply with quote

Hello,

I've been investigating PHP's source code and coded this patches, those allow build Apache 2.4 SAPI putting the includes/libs in their locations and adding a --enable-apache2-4handler configure command

PHP 5.2:
Code:

diff -uNr php5.2-201103172330/main/network.c php5.2-new/main/network.c
--- php5.2-201103172330/main/network.c   Sun Jan  3 09:42:23 2010
+++ php5.2-new/main/network.c   Fri Jun  8 02:00:24 2012
@@ -90,6 +90,11 @@
 # define SOCK_ERR INVALID_SOCKET
 # define SOCK_CONN_ERR SOCKET_ERROR
 # define PHP_TIMEOUT_ERROR_VALUE      WSAETIMEDOUT
+
+#if HAVE_IPV6
+const struct in6_addr in6addr_any = {0}; /* IN6ADDR_ANY_INIT; */
+#endif
+
 #else
 # define SOCK_ERR -1
 # define SOCK_CONN_ERR -1
@@ -331,8 +336,18 @@
    if (n == 0) {
       goto ok;
    }
-
+# ifdef PHP_WIN32
+   /* The documentation for connect() says in case of non-blocking connections
+    * the select function reports success in the writefds set and failure in
+    * the exceptfds set. Indeed, using PHP_POLLREADABLE results in select
+    * failing only due to the timeout and not immediately as would be
+    * expected when a connection is actively refused. This way,
+    * php_pollfd_for will return a mask with POLLOUT if the connection
+    * is successful and with POLLPRI otherwise. */
+   if ((n = php_pollfd_for(sockfd, POLLOUT|POLLPRI, timeout)) == 0) {
+#else
    if ((n = php_pollfd_for(sockfd, PHP_POLLREADABLE|POLLOUT, timeout)) == 0) {
+#endif
       error = PHP_TIMEOUT_ERROR_VALUE;
    }
 
@@ -360,9 +375,11 @@
       *error_code = error;
    }
 
-   if (error && error_string) {
-      *error_string = php_socket_strerror(error, NULL, 0);
+   if (error) {
       ret = -1;
+      if (error_string) {
+         *error_string = php_socket_strerror(error, NULL, 0);
+      }
    }
    return ret;
 #else
diff -uNr php5.2-201103172330/main/php_network.h php5.2-new/main/php_network.h
--- php5.2-201103172330/main/php_network.h   Sun Jan  3 09:42:23 2010
+++ php5.2-new/main/php_network.h   Fri Jun  8 01:50:11 2012
@@ -31,6 +32,10 @@
    * it to something that breaks the windows headers */
 # undef strtoul
 /* defines socklen_t and some IPV6 stuff */
+# if _MSC_VER >= 1500
+#  include <In6addr.h>
+#  include <winsock2.h>
+# endif
 # include <ws2tcpip.h>
 # if HAVE_WSPIAPI_H
    /* getaddrinfo */
diff -uNr php5.2-201103172330/sapi/apache2handler/apache_config.c php5.2-new/sapi/apache2handler/apache_config.c
--- php5.2-201103172330/sapi/apache2handler/apache_config.c   Sun Jan  3 09:41:51 2010
+++ php5.2-new/sapi/apache2handler/apache_config.c   Fri Jun  8 11:50:41 2012
@@ -22,6 +22,7 @@
 
 #include "php.h"
 #include "php_ini.h"
+#include "php_network.h"
 #include "php_apache.h"
 
 #include "apr_strings.h"
@@ -138,11 +139,13 @@
 void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf)
 {
    php_conf_rec *d = base_conf, *e = new_conf, *n = NULL;
+#if STAS_0
    php_dir_entry *pe;
    php_dir_entry *data;
    char *str;
    uint str_len;
    ulong num_index;
+#endif
 
    n = create_php_config(p, "merge_php_config");
    /* copy old config */
@@ -190,11 +193,12 @@
          zend_hash_get_current_key_ex(&d->config, &str, &str_len, NULL, 0,
             NULL) == HASH_KEY_IS_STRING;
          zend_hash_move_forward(&d->config)) {
-      zend_hash_get_current_data(&d->config, (void **) &data);
-      phpapdebug((stderr, "APPLYING (%s)(%s)\n", str, data->value));
-      if (zend_alter_ini_entry(str, str_len, data->value, data->value_len, data->status, data->htaccess?PHP_INI_STAGE_HTACCESS:PHP_INI_STAGE_ACTIVATE) == FAILURE) {
-         phpapdebug((stderr, "..FAILED\n"));
-      }   
+      if (zend_hash_get_current_data(&d->config, (void **) &data) == SUCCESS) {
+         phpapdebug((stderr, "APPLYING (%s)(%s)\n", str, data->value));
+         if (zend_alter_ini_entry(str, str_len, data->value, data->value_len, data->status, data->htaccess?PHP_INI_STAGE_HTACCESS:PHP_INI_STAGE_ACTIVATE) == FAILURE) {
+            phpapdebug((stderr, "..FAILED\n"));
+         }
+      }
    }
 }
 
diff -uNr php5.2-201103172330/sapi/apache2handler/config.w32 php5.2-new/sapi/apache2handler/config.w32
--- php5.2-201103172330/sapi/apache2handler/config.w32   Fri Jul 17 13:16:21 2009
+++ php5.2-new/sapi/apache2handler/config.w32   Fri Jun  8 10:01:25 2012
@@ -1,10 +1,11 @@
 // vim:ft=javascript
-// $Id: config.w32 234960 2007-05-04 18:17:55Z edink $
+// $Id$
 
 ARG_ENABLE('apache2handler', 'Build Apache 2.x handler', 'no');
-
 if (PHP_APACHE2HANDLER != "no") {
-   if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2HANDLER", PHP_PHP_BUILD + "\\include\\apache2") &&
+   if (PHP_ZTS == "no") {
+      WARNING("Apache 2.0 module requires an --enable-zts build of PHP on windows");
+   } else if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2HANDLER", PHP_PHP_BUILD + "\\include\\apache2") &&
          CHECK_LIB("libhttpd.lib", "apache2handler", PHP_PHP_BUILD + "\\lib\\apache2") &&
          CHECK_LIB("libapr.lib", "apache2handler", PHP_PHP_BUILD + "\\lib\\apache2") &&
          CHECK_LIB("libaprutil.lib", "apache2handler", PHP_PHP_BUILD + "\\lib\\apache2")
@@ -18,9 +19,10 @@
 }
 
 ARG_ENABLE('apache2-2handler', 'Build Apache 2.2.x handler', 'no');
-
 if (PHP_APACHE2_2HANDLER != "no") {
-   if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2_2HANDLER", PHP_PHP_BUILD + "\\include\\apache2_2") &&
+   if (PHP_ZTS == "no") {
+      WARNING("Apache 2.2 module requires an --enable-zts build of PHP on windows");
+   } else if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2_2HANDLER", PHP_PHP_BUILD + "\\include\\apache2_2") &&
          CHECK_LIB("libhttpd.lib", "apache2_2handler", PHP_PHP_BUILD + "\\lib\\apache2_2") &&
          CHECK_LIB("libapr-1.lib", "apache2_2handler", PHP_PHP_BUILD + "\\lib\\apache2_2") &&
          CHECK_LIB("libaprutil-1.lib", "apache2_2handler", PHP_PHP_BUILD + "\\lib\\apache2_2")
@@ -33,3 +35,21 @@
       WARNING("Could not find apache2.2 libraries/headers");
    }
 }
+
+ARG_ENABLE('apache2-4handler', 'Build Apache 2.4.x handler', 'no');
+if (PHP_APACHE2_4HANDLER != "no") {
+   if (PHP_ZTS == "no") {
+      WARNING("Apache 2.4 module requires an --enable-zts build of PHP on windows");
+   } else if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2_4HANDLER", PHP_PHP_BUILD + "\\include\\apache2_4") &&
+         CHECK_LIB("libhttpd.lib", "apache2_4handler", PHP_PHP_BUILD + "\\lib\\apache2_4") &&
+         CHECK_LIB("libapr-1.lib", "apache2_4handler", PHP_PHP_BUILD + "\\lib\\apache2_4") &&
+         CHECK_LIB("libaprutil-1.lib", "apache2_4handler", PHP_PHP_BUILD + "\\lib\\apache2_4")
+         ) {
+      SAPI('apache2_4handler', 'mod_php5.c sapi_apache2.c apache_config.c php_functions.c',
+            'php' + PHP_VERSION + 'apache2_4.dll',
+            '/D PHP_APACHE2_EXPORTS /I win32',
+            'sapi\\apache2handler');
+   } else {
+      WARNING("Could not find apache2.4 libraries/headers");
+   }
+}
\ No newline at end of file
diff -uNr php5.2-201103172330/sapi/apache2handler/mod_php5.c php5.2-new/sapi/apache2handler/mod_php5.c
--- php5.2-201103172330/sapi/apache2handler/mod_php5.c   Sun Jan  3 09:41:51 2010
+++ php5.2-new/sapi/apache2handler/mod_php5.c   Fri Jun  8 11:50:57 2012
@@ -23,6 +23,7 @@
 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
 
 #include "php.h"
+#include "php_network.h"
 #include "php_apache.h"
 
 AP_MODULE_DECLARE_DATA module php5_module = {
diff -uNr php5.2-201103172330/sapi/apache2handler/php_apache.h php5.2-new/sapi/apache2handler/php_apache.h
--- php5.2-201103172330/sapi/apache2handler/php_apache.h   Sun Jan  3 09:41:51 2010
+++ php5.2-new/sapi/apache2handler/php_apache.h   Fri Jun  8 11:51:34 2012
@@ -82,5 +82,10 @@
 #define AP2(v) (php_apache2_info.v)
 #endif
 
+/* fix for gcc4 visibility patch */
+#ifndef PHP_WIN32
+# undef AP_MODULE_DECLARE_DATA
+# define AP_MODULE_DECLARE_DATA PHPAPI
+#endif
 
 #endif /* PHP_APACHE_H */
diff -uNr php5.2-201103172330/sapi/apache2handler/php_functions.c php5.2-new/sapi/apache2handler/php_functions.c
--- php5.2-201103172330/sapi/apache2handler/php_functions.c   Sun Jan  3 09:41:51 2010
+++ php5.2-new/sapi/apache2handler/php_functions.c   Fri Jun  8 11:51:04 2012
@@ -25,6 +25,7 @@
 #include "ext/standard/info.h"
 #include "ext/standard/head.h"
 #include "php_ini.h"
+#include "php_network.h"
 #include "SAPI.h"
 
 #define CORE_PRIVATE
diff -uNr php5.2-201103172330/sapi/apache2handler/sapi_apache2.c php5.2-new/sapi/apache2handler/sapi_apache2.c
--- php5.2-201103172330/sapi/apache2handler/sapi_apache2.c   Mon May  3 21:39:54 2010
+++ php5.2-new/sapi/apache2handler/sapi_apache2.c   Fri Jun  8 11:51:11 2012
@@ -25,6 +25,7 @@
 #include "php.h"
 #include "php_main.h"
 #include "php_ini.h"
+#include "php_network.h"
 #include "php_variables.h"
 #include "SAPI.h"
 



PHP 5.3:
Code:
diff -uNr php5.3-201206072130/sapi/apache2handler/apache_config.c php5.3-new/sapi/apache2handler/apache_config.c
--- php5.3-201206072130/sapi/apache2handler/apache_config.c   Wed May 16 17:59:06 2012
+++ php5.3-new/sapi/apache2handler/apache_config.c   Fri Jun  8 09:58:15 2012
@@ -22,6 +22,7 @@
 
 #include "php.h"
 #include "php_ini.h"
+#include "php_network.h"
 #include "php_apache.h"
 
 #include "apr_strings.h"
diff -uNr php5.3-201206072130/sapi/apache2handler/config.w32 php5.3-new/sapi/apache2handler/config.w32
--- php5.3-201206072130/sapi/apache2handler/config.w32   Wed May 16 17:59:06 2012
+++ php5.3-new/sapi/apache2handler/config.w32   Fri Jun  8 10:01:25 2012
@@ -2,10 +2,9 @@
 // $Id$
 
 ARG_ENABLE('apache2handler', 'Build Apache 2.x handler', 'no');
-
 if (PHP_APACHE2HANDLER != "no") {
    if (PHP_ZTS == "no") {
-      WARNING("Apache2 module requires an --enable-zts build of PHP on windows");
+      WARNING("Apache 2.0 module requires an --enable-zts build of PHP on windows");
    } else if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2HANDLER", PHP_PHP_BUILD + "\\include\\apache2") &&
          CHECK_LIB("libhttpd.lib", "apache2handler", PHP_PHP_BUILD + "\\lib\\apache2") &&
          CHECK_LIB("libapr.lib", "apache2handler", PHP_PHP_BUILD + "\\lib\\apache2") &&
@@ -20,10 +19,9 @@
 }
 
 ARG_ENABLE('apache2-2handler', 'Build Apache 2.2.x handler', 'no');
-
 if (PHP_APACHE2_2HANDLER != "no") {
    if (PHP_ZTS == "no") {
-      WARNING("Apache2 module requires an --enable-zts build of PHP on windows");
+      WARNING("Apache 2.2 module requires an --enable-zts build of PHP on windows");
    } else if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2_2HANDLER", PHP_PHP_BUILD + "\\include\\apache2_2") &&
          CHECK_LIB("libhttpd.lib", "apache2_2handler", PHP_PHP_BUILD + "\\lib\\apache2_2") &&
          CHECK_LIB("libapr-1.lib", "apache2_2handler", PHP_PHP_BUILD + "\\lib\\apache2_2") &&
@@ -37,3 +35,21 @@
       WARNING("Could not find apache2.2 libraries/headers");
    }
 }
+
+ARG_ENABLE('apache2-4handler', 'Build Apache 2.4.x handler', 'no');
+if (PHP_APACHE2_4HANDLER != "no") {
+   if (PHP_ZTS == "no") {
+      WARNING("Apache 2.4 module requires an --enable-zts build of PHP on windows");
+   } else if (CHECK_HEADER_ADD_INCLUDE("httpd.h", "CFLAGS_APACHE2_4HANDLER", PHP_PHP_BUILD + "\\include\\apache2_4") &&
+         CHECK_LIB("libhttpd.lib", "apache2_4handler", PHP_PHP_BUILD + "\\lib\\apache2_4") &&
+         CHECK_LIB("libapr-1.lib", "apache2_4handler", PHP_PHP_BUILD + "\\lib\\apache2_4") &&
+         CHECK_LIB("libaprutil-1.lib", "apache2_4handler", PHP_PHP_BUILD + "\\lib\\apache2_4")
+         ) {
+      SAPI('apache2_4handler', 'mod_php5.c sapi_apache2.c apache_config.c php_functions.c',
+            'php' + PHP_VERSION + 'apache2_4.dll',
+            '/D PHP_APACHE2_EXPORTS /I win32',
+            'sapi\\apache2handler');
+   } else {
+      WARNING("Could not find apache2.4 libraries/headers");
+   }
+}
\ No newline at end of file
diff -uNr php5.3-201206072130/sapi/apache2handler/mod_php5.c php5.3-new/sapi/apache2handler/mod_php5.c
--- php5.3-201206072130/sapi/apache2handler/mod_php5.c   Wed May 16 17:59:06 2012
+++ php5.3-new/sapi/apache2handler/mod_php5.c   Fri Jun  8 09:58:22 2012
@@ -23,6 +23,7 @@
 #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
 
 #include "php.h"
+#include "php_network.h"
 #include "php_apache.h"
 
 AP_MODULE_DECLARE_DATA module php5_module = {
diff -uNr php5.3-201206072130/sapi/apache2handler/php_functions.c php5.3-new/sapi/apache2handler/php_functions.c
--- php5.3-201206072130/sapi/apache2handler/php_functions.c   Wed May 16 17:59:06 2012
+++ php5.3-new/sapi/apache2handler/php_functions.c   Fri Jun  8 09:58:30 2012
@@ -25,6 +25,7 @@
 #include "ext/standard/info.h"
 #include "ext/standard/head.h"
 #include "php_ini.h"
+#include "php_network.h"
 #include "SAPI.h"
 
 #define CORE_PRIVATE
diff -uNr php5.3-201206072130/sapi/apache2handler/sapi_apache2.c php5.3-new/sapi/apache2handler/sapi_apache2.c
--- php5.3-201206072130/sapi/apache2handler/sapi_apache2.c   Wed May 16 17:59:06 2012
+++ php5.3-new/sapi/apache2handler/sapi_apache2.c   Fri Jun  8 09:58:38 2012
@@ -25,6 +25,7 @@
 #include "php.h"
 #include "php_main.h"
 #include "php_ini.h"
+#include "php_network.h"
 #include "php_variables.h"
 #include "SAPI.h"
 
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Fri 08 Jun '12 19:39    Post subject: Reply with quote

Did you send those patches to the PHP Dev's?
Back to top
NewEraCracker



Joined: 23 Aug 2010
Posts: 36

PostPosted: Fri 08 Jun '12 20:12    Post subject: Reply with quote

I've submitted PHP 5.3 patch:
https://bugs.php.net/bug.php?id=62267
Back to top
SolidSnakeGTI



Joined: 16 May 2012
Posts: 16

PostPosted: Sun 05 Aug '12 20:37    Post subject: Reply with quote

Thank you, your patch was a good starting point for me to compile php5apache2_4.dll

I've submitted an updated patch in same bug report to solve my issue reported here:
http://www.apachelounge.com/viewtopic.php?p=22239#22239

Please review it & let me know if you've any comments.

P.S. I've submitted two patches actually, if you can please delete the first one of them. It's submitted by mistake:
https://bugs.php.net/patch-display.php?bug_id=62267&patch=php-5.4-apache-2.4&revision=latest
Back to top


Reply to topic   Topic: PHP 5.2 and PHP 5.3 apache2handler patch for 2.4 View previous topic :: View next topic
Post new topic   Forum Index -> Other Software