helly           Fri May 30 11:42:46 2003 EDT

  Modified files:              
    /php4/ext/pgsql     pgsql.c 
    /php4/ext/pgsql/tests       09notice.phpt 
  Log:
  Fix notice handling
  
Index: php4/ext/pgsql/pgsql.c
diff -u php4/ext/pgsql/pgsql.c:1.272 php4/ext/pgsql/pgsql.c:1.273
--- php4/ext/pgsql/pgsql.c:1.272        Fri May 30 11:07:01 2003
+++ php4/ext/pgsql/pgsql.c      Fri May 30 11:42:46 2003
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: pgsql.c,v 1.272 2003/05/30 15:07:01 helly Exp $ */
+/* $Id: pgsql.c,v 1.273 2003/05/30 15:42:46 helly Exp $ */
 
 #include <stdlib.h>
 
@@ -264,15 +264,21 @@
 static void _php_pgsql_notice_handler(void *resource_id, const char *message)
 {
        php_pgsql_notice *notice;
+       int i;
        
        TSRMLS_FETCH();
        if (! PGG(ignore_notices)) {
+               notice = (php_pgsql_notice *)emalloc(sizeof(php_pgsql_notice));
+               i = strlen(message)-1;
+               while (i && (message[i] == '\r' || message[i] == '\n')) {
+                       i--;
+               }
+               i++;
+               notice->message = estrndup(message, i);
+               notice->len = i;
                if (PGG(log_notices)) {
-                       php_log_err((char *) message TSRMLS_CC);
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s", 
notice->message);
                }
-               notice = (php_pgsql_notice *)emalloc(sizeof(php_pgsql_notice));
-               notice->len = strlen(message);
-               notice->message = estrndup(message, notice->len);
                zend_hash_index_update(&PGG(notices), *(int *)resource_id, (void 
**)&notice, sizeof(php_pgsql_notice *), NULL);
        }
 }
Index: php4/ext/pgsql/tests/09notice.phpt
diff -u php4/ext/pgsql/tests/09notice.phpt:1.4 php4/ext/pgsql/tests/09notice.phpt:1.5
--- php4/ext/pgsql/tests/09notice.phpt:1.4      Fri May 30 11:07:02 2003
+++ php4/ext/pgsql/tests/09notice.phpt  Fri May 30 11:42:46 2003
@@ -18,12 +18,11 @@
        echo "Cannot find notice message in hash\n";
        var_dump($msg);
 }
-echo $msg;
+echo $msg."\n";
 echo "pg_last_notice() is Ok\n";
 
 ?>
---EXPECT--
-NOTICE:  BEGIN: already a transaction in progress
-
+--EXPECTF--
+Notice: pg_query(): NOTICE:  BEGIN: already a transaction in progress in %s on line %d
 NOTICE:  BEGIN: already a transaction in progress
 pg_last_notice() is Ok



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

Reply via email to