Re: cvs: php-src(PHP_5_1) /ext/pdo pdo.c
| From: | Marcus Boerger | Date: | Wed, 05 Oct 2005 18:49:57 +0000 |
| Subject: | Re: cvs: php-src(PHP_5_1) /ext/pdo pdo.c | ||
| References: | 1 2 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-34324@lists.php.net to get a copy of this message | ||
Hello Jani,
how does this break the build?
the reason for this 'workaround' is to fetch the class dynamically from the
compiler classs hash rather than using the global pointer. For some reason
it seems that the global pointer is not valid during PDO's MINIT in second
apache 1.* startup stage. However, if you disable SPL the class is simply
not available and you fallback to Exception as PDOException base just like
you did before the patch.
marcus
Wednesday, October 5, 2005, 6:32:58 PM, you wrote:
> If I have --enable-pdo, this would break the build
> since I have --disable-spl.. :)
> --Jani
> On Wed, 5 Oct 2005, Derick Rethans wrote:
>>
>> derick Wed Oct 5 09:51:49 2005 EDT
>>
>> Modified files: (Branch: PHP_5_1)
>> /php-src/ext/pdo pdo.c
>> Log:
>> - Committing some changes that make PDO+SPL not crash anymore. These are done
>> by Marcus. and I'm committing them in order to actually use PHP 5.1 without
>> segfaulting when apache starts. This is not necessary the best solution.
>>
>>
>> 3)ºC,m
>> ñâì5®¯v9ƒhttp://cvs.php.net/diff.php/php-src/ext/pdo/pdo.c?r1=1.57.2.8&r2=1.57.2.9&ty=uŠy‰Qe9åÅ
>> 5£[
>> Index: php-src/ext/pdo/pdo.c
>> diff -u php-src/ext/pdo/pdo.c:1.57.2.8 php-src/ext/pdo/pdo.c:1.57.2.9
>> --- php-src/ext/pdo/pdo.c:1.57.2.8 Sun Oct 2 16:38:18 2005
>> +++ php-src/ext/pdo/pdo.c Wed Oct 5 09:51:46 2005
>> @@ -18,7 +18,7 @@
>> +----------------------------------------------------------------------+
>> */
>>
>> -/* $Id: pdo.c,v 1.57.2.8 2005/10/02 20:38:18 helly Exp $ */
>> +/* $Id: pdo.c,v 1.57.2.9 2005/10/05 13:51:46 derick Exp $ */
>>
>> #ifdef HAVE_CONFIG_H
>> #include "config.h"
>> @@ -33,9 +33,7 @@
>> #include "php_pdo_int.h"
>> #include "zend_exceptions.h"
>>
>> -#if defined(HAVE_SPL) && ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5
>> && PHP_MINOR_VERSION >= 1))
>> -extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
>> -#endif
>> +static zend_class_entry *spl_ce_RuntimeException;
>>
>> ZEND_DECLARE_MODULE_GLOBALS(pdo)
>>
>> @@ -64,7 +62,16 @@
>> {
>> #if can_handle_soft_dependency_on_SPL && defined(HAVE_SPL) &&
>> ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1))
>> if (!root) {
>> - return spl_ce_RuntimeException;
>> + if (!spl_ce_RuntimeException) {
>> + zend_class_entry **pce;
>> +
>> + if (zend_hash_find(CG(class_table), "runtimeexception",
>> sizeof("RuntimeException"), (void **) &pce) == SUCCESS) {
>> + spl_ce_RuntimeException = *pce;
>> + return *pce;
>> + }
>> + } else {
>> + return spl_ce_RuntimeException;
>> + }
>> }
>> #endif
>> #if (PHP_MAJOR_VERSION < 6)
>> @@ -295,7 +302,9 @@
>> /* {{{ PHP_MINIT_FUNCTION */
>> PHP_MINIT_FUNCTION(pdo)
>> {
>> - zend_class_entry ce;
>> + zend_class_entry ce, *pce;
>> +
>> + spl_ce_RuntimeException = NULL;
>>
>> ZEND_INIT_MODULE_GLOBALS(pdo, php_pdo_init_globals, NULL);
>> REGISTER_INI_ENTRIES();
>> @@ -310,11 +319,9 @@
>> "PDO persistent database", module_number);
>>
>> INIT_CLASS_ENTRY(ce, "PDOException", NULL);
>> -#if can_handle_soft_dependency_on_SPL && defined(HAVE_SPL) &&
>> ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1))
>> - pdo_exception_ce = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException,
>> NULL TSRMLS_CC);
>> -#else
>> - pdo_exception_ce = zend_register_internal_class_ex(&ce,
>> zend_exception_get_default(), NULL TSRMLS_CC);
>> -#endif
>> +
>> + pdo_exception_ce = zend_register_internal_class_ex(&ce,
>> php_pdo_get_exception_base(0 TSRMLS_CC), NULL TSRMLS_CC);
>> +
>> zend_declare_property_null(pdo_exception_ce, "errorInfo",
>> sizeof("errorInfo")-1, ZEND_ACC_PUBLIC TSRMLS_CC);
>>
>> pdo_dbh_init(TSRMLS_C);
>>
>>
> --
> Give me your money at @
> <http://pecl.php.net/wishlist.php/sniper>
> Donating money may make me happier and friendlier for a limited period!
> Death to all 4 letter abbreviations starting with P!
Best regards,
Marcus