]> granicus.if.org Git - php/commitdiff
Fix notice handling
authorMarcus Boerger <helly@php.net>
Fri, 30 May 2003 15:42:46 +0000 (15:42 +0000)
committerMarcus Boerger <helly@php.net>
Fri, 30 May 2003 15:42:46 +0000 (15:42 +0000)
ext/pgsql/pgsql.c
ext/pgsql/tests/09notice.phpt

index a77c80da16796ca5997fa0ce5a503d507f11f6ba..99f5a74f21dd0f48bb94fa63f285552754f5c0e5 100644 (file)
@@ -264,15 +264,21 @@ static void _close_pgsql_plink(zend_rsrc_list_entry *rsrc TSRMLS_DC)
 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 55bbd28ed1b86250d0ed417021c2ef94bf5f79b1..a2955b5c52862a54a0b5eee964c4ace71df95f0a 100644 (file)
@@ -18,12 +18,11 @@ if ($msg === FALSE) {
        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