Ticket #252 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

PHP version check should not block PHP when version mismatch is found

Reported by: tigertech Assigned to: bart
Priority: minor Milestone: 0.9.6
Component: eAccelerator Version:
Keywords: version Cc:

Description (Last modified by bart)

I work for a hosting company (http://www.tigertech.net/) using eAccelerator with PHP/FastCGI.

By default, eAccelerator returns FAILURE if the version of PHP doesn't match the exact version it was compiled for. This makes upgrades difficult: even if you recompile both PHP and eAccelerator, any PHP/FastCGI instances that launch between the time PHP and eAccelerator are upgraded (probably a few seconds) will completely fail.

We used to deal with this by disabling eAccelerator during PHP upgrades, but that's error-prone (easy to forget). We patched eAccelerator as follows -- it causes eAccelerator to still log an error and bail out before doing anything, but return SUCCESS instead of FAILURE so that the PHP instance can continue (albeit without eAccelerator support).

--- php5-eaccelerator-0.9.5.orig/eaccelerator.c	2006-10-11 05:45:52.000000000 -0700
+++ php5-eaccelerator-0.9.5/eaccelerator.c	2007-05-01 13:02:09.000000000 -0700
@@ -1946,11 +1946,15 @@
         strcmp(Z_STRVAL(v),PHP_VERSION) == 0) {
       ret = 1;
     } else {
-      zend_error(E_CORE_WARNING,"[%s] This build of \"%s\" was compiled for PHP version %s. Rebuild it for your PHP version (%s) or download precompiled binaries.\n", EACCELERATOR_EXTENSION_NAME,EACCELERATOR_EXTENSION_NAME,PHP_VERSION,Z_STRVAL(v));
+      /* tigertech: use fprintf instead of zend_error, because zend_error prints
+         to stdout which confuses mod_fcgid */
+      fprintf(stderr,"[%s] This build of \"%s\" was compiled for PHP version %s. Rebuild it for your PHP version (%s) or download precompiled binaries.\n", EACCELERATOR_EXTENSION_NAME,EACCELERATOR_EXTENSION_NAME,PHP_VERSION,Z_STRVAL(v));
     }
     zval_dtor(&v);
   } else {
-    zend_error(E_CORE_WARNING,"[%s] This build of \"%s\" was compiled for PHP version %s. Rebuild it for your PHP version.\n", EACCELERATOR_EXTENSION_NAME,EACCELERATOR_EXTENSION_NAME,PHP_VERSION);
+    /* tigertech: use fprintf instead of zend_error, because zend_error prints
+       to stdout which confuses mod_fcgid */
+    fprintf(stderr,"[%s] This build of \"%s\" was compiled for PHP version %s. Rebuild it for your PHP version.\n", EACCELERATOR_EXTENSION_NAME,EACCELERATOR_EXTENSION_NAME,PHP_VERSION);
   }
   return ret;
 }
@@ -1998,7 +2002,9 @@
 #endif
   }
   if (!eaccelerator_check_php_version(TSRMLS_C)) {
-    return FAILURE;
+    /* tigertech: do not return FAILURE, because it causes PHP to
+       completely fail. */
+    return SUCCESS;
   }
   ZEND_INIT_MODULE_GLOBALS(eaccelerator, eaccelerator_init_globals, NULL);
   REGISTER_INI_ENTRIES();

Change History

05/06/07 21:24:40 changed by bart

  • owner changed from somebody to bart.
  • milestone set to 0.9.6.

I've got bitten by that to quite some times. I'll certainly include this in the next release if the others like it too.

05/10/07 23:08:59 changed by bart

  • description changed.

05/11/07 00:34:06 changed by bart

  • status changed from new to closed.
  • resolution set to fixed.

This patch was commited in revision [309]