sixd                                     Fri, 05 Mar 2010 06:45:28 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=295847

Log:
Fixed bug #51086 (DBA DB4 doesn't work with Berkeley DB 4.8)

Bug: http://bugs.php.net/51086 (Assigned) will not work with libdb4.8
      
Changed paths:
    U   php/php-src/branches/PHP_5_2/NEWS
    U   php/php-src/branches/PHP_5_2/ext/dba/dba_db4.c
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/dba/dba_db4.c
    U   php/php-src/trunk/ext/dba/dba_db4.c

Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS   2010-03-05 06:13:08 UTC (rev 295846)
+++ php/php-src/branches/PHP_5_2/NEWS   2010-03-05 06:45:28 UTC (rev 295847)
@@ -9,6 +9,8 @@
   (Ilia)
 - Fixed bug #51171 (curl_setopt() doesn't output any errors or warnings when
   an invalid option is provided). (Ilia)
+- Fixed bug #51086 (DBA DB4 doesn't work with Berkeley DB 4.8). (Chris Jones)
+- Fixed bug #51062 (DBA DB4 uses mismatched headers and libraries). (Chris 
Jones)
 - Fixed bug #43314 (iconv_mime_encode(), broken Q scheme). (Rasmus)
 - Fixed bug #23229 (syslog function truncates messages). (Adam)


Modified: php/php-src/branches/PHP_5_2/ext/dba/dba_db4.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/dba/dba_db4.c      2010-03-05 06:13:08 UTC 
(rev 295846)
+++ php/php-src/branches/PHP_5_2/ext/dba/dba_db4.c      2010-03-05 06:45:28 UTC 
(rev 295847)
@@ -43,6 +43,18 @@
        const char *errpfx, const char *msg)
 {
        TSRMLS_FETCH();
+
+#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8 && DB_VERSION_PATCH <= 26)
+/* Bug 51086, Berkeley DB 4.8.26 */
+/* This code suppresses a BDB 4.8 error message that BDB incorrectly emits */
+       {
+               char *function = get_active_function_name(TSRMLS_C);
+               if (function && (!strcmp(function,"dba_popen") || 
!strcmp(function,"dba_open"))
+                       && !strncmp(msg, "fop_read_meta", 
sizeof("fop_read_meta")-1)) {
+                       return;
+               }
+       }
+#endif

        php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s%s", errpfx?errpfx:"", 
msg);
 }
@@ -67,6 +79,7 @@
        struct stat check_stat;
        int s = VCWD_STAT(info->path, &check_stat);

+#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 7)  /* Bug 51086 */
        if (!s && !check_stat.st_size) {
                info->mode = DBA_TRUNC; /* force truncate */
        }
@@ -80,7 +93,21 @@
                (info->mode == DBA_CREAT && !s) ? 0 :
                info->mode == DBA_WRITER ? 0         :
                info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1;
+#else
+       if (!s && !check_stat.st_size) {
+               info->mode = DBA_CREAT; /* force creation */
+       }

+       type = info->mode == DBA_READER ? DB_UNKNOWN :
+               (info->mode == DBA_TRUNC || info->mode == DBA_CREAT) ? DB_BTREE 
:
+               s ? DB_BTREE : DB_UNKNOWN;
+
+       gmode = info->mode == DBA_READER ? DB_RDONLY :
+               info->mode == DBA_CREAT ? DB_CREATE :
+               info->mode == DBA_WRITER ? 0         :
+               info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1;
+#endif
+
        if (gmode == -1) {
                return FAILURE; /* not possible */
        }

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2010-03-05 06:13:08 UTC (rev 295846)
+++ php/php-src/branches/PHP_5_3/NEWS   2010-03-05 06:45:28 UTC (rev 295847)
@@ -12,6 +12,8 @@
   (Felipe)
 - Fixed bug #51171 (curl_setopt() doesn't output any errors or warnings when
   an invalid option is provided). (Ilia)
+- Fixed bug #51086 (DBA DB4 doesn't work with Berkeley DB 4.8). (Chris Jones)
+- Fixed bug #51062 (DBA DB4 uses mismatched headers and libraries). (Chris 
Jones)
 - Fixed bug #50999 (unaligned memory access in dba_fetch()). (Felipe)
 - Fixed bug #50731 (Inconsistent namespaces sent to functions registered with
   spl_autoload_register). (Felipe)

Modified: php/php-src/branches/PHP_5_3/ext/dba/dba_db4.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/dba/dba_db4.c      2010-03-05 06:13:08 UTC 
(rev 295846)
+++ php/php-src/branches/PHP_5_3/ext/dba/dba_db4.c      2010-03-05 06:45:28 UTC 
(rev 295847)
@@ -43,7 +43,19 @@
        const char *errpfx, const char *msg)
 {
        TSRMLS_FETCH();
-
+
+#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8 && DB_VERSION_PATCH <= 26)
+/* Bug 51086, Berkeley DB 4.8.26 */
+/* This code suppresses a BDB 4.8 error message that BDB incorrectly emits */
+       {
+               char *function = get_active_function_name(TSRMLS_C);
+               if (function && (!strcmp(function,"dba_popen") || 
!strcmp(function,"dba_open"))
+                       && !strncmp(msg, "fop_read_meta", 
sizeof("fop_read_meta")-1)) {
+                       return;
+               }
+       }
+#endif
+
        php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s%s", errpfx?errpfx:"", 
msg);
 }

@@ -67,6 +79,7 @@
        struct stat check_stat;
        int s = VCWD_STAT(info->path, &check_stat);

+#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 7)  /* Bug 51086 */
        if (!s && !check_stat.st_size) {
                info->mode = DBA_TRUNC; /* force truncate */
        }
@@ -80,7 +93,21 @@
                (info->mode == DBA_CREAT && !s) ? 0 :
                info->mode == DBA_WRITER ? 0         :
                info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1;
+#else
+       if (!s && !check_stat.st_size) {
+               info->mode = DBA_CREAT; /* force creation */
+       }

+       type = info->mode == DBA_READER ? DB_UNKNOWN :
+               (info->mode == DBA_TRUNC || info->mode == DBA_CREAT) ? DB_BTREE 
:
+               s ? DB_BTREE : DB_UNKNOWN;
+
+       gmode = info->mode == DBA_READER ? DB_RDONLY :
+               info->mode == DBA_CREAT ? DB_CREATE :
+               info->mode == DBA_WRITER ? 0         :
+               info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1;
+#endif
+
        if (gmode == -1) {
                return FAILURE; /* not possible */
        }

Modified: php/php-src/trunk/ext/dba/dba_db4.c
===================================================================
--- php/php-src/trunk/ext/dba/dba_db4.c 2010-03-05 06:13:08 UTC (rev 295846)
+++ php/php-src/trunk/ext/dba/dba_db4.c 2010-03-05 06:45:28 UTC (rev 295847)
@@ -40,9 +40,30 @@
 #if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
        const DB_ENV *dbenv,
 #endif
-       const char *errpfx, char *msg)
+       const char *errpfx, const char *msg)
 {
        TSRMLS_FETCH();
+
+#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8 && DB_VERSION_PATCH <= 26)
+/* Bug 51086, Berkeley DB 4.8.26 */
+/* This code suppresses a BDB 4.8 error message that BDB incorrectly emits */
+       {
+               zstr funcname = get_active_function_name(TSRMLS_C);
+               int s_funcname_len;
+               char *s_funcname;
+               if (funcname.u != NULL) {
+                       zend_unicode_to_string(ZEND_U_CONVERTER(UG(utf8_conv)), 
&s_funcname, &s_funcname_len, funcname.u, u_strlen(funcname.u) TSRMLS_CC);
+
+                       if (s_funcname != NULL && 
(!strcmp(s_funcname,"dba_popen") || !strcmp(s_funcname,"dba_open"))
+                               && !strncmp(msg, "fop_read_meta", 
sizeof("fop_read_meta")-1)) {
+                               efree(s_funcname);
+                               return;
+                       }
+                       if (s_funcname != NULL)
+                               efree(s_funcname);
+               }
+       }
+#endif

        php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s%s", errpfx?errpfx:"", 
msg);
 }
@@ -67,6 +88,7 @@
        struct stat check_stat;
        int s = VCWD_STAT(info->path, &check_stat);

+#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 7)  /* Bug 51086 */
        if (!s && !check_stat.st_size) {
                info->mode = DBA_TRUNC; /* force truncate */
        }
@@ -80,7 +102,21 @@
                (info->mode == DBA_CREAT && !s) ? 0 :
                info->mode == DBA_WRITER ? 0         :
                info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1;
+#else
+       if (!s && !check_stat.st_size) {
+               info->mode = DBA_CREAT; /* force creation */
+       }

+       type = info->mode == DBA_READER ? DB_UNKNOWN :
+               (info->mode == DBA_TRUNC || info->mode == DBA_CREAT) ? DB_BTREE 
:
+               s ? DB_BTREE : DB_UNKNOWN;
+
+       gmode = info->mode == DBA_READER ? DB_RDONLY :
+               info->mode == DBA_CREAT ? DB_CREATE :
+               info->mode == DBA_WRITER ? 0         :
+               info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1;
+#endif
+
        if (gmode == -1) {
                return FAILURE; /* not possible */
        }

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to