From: Marcus Boerger Date: Fri, 30 May 2003 15:42:46 +0000 (+0000) Subject: Fix notice handling X-Git-Tag: RELEASE_1_0_2~513 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3dbe16cac4fbc002c4020c12e132cda41e89bf21;p=php Fix notice handling --- diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index a77c80da16..99f5a74f21 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -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 **)¬ice, sizeof(php_pgsql_notice *), NULL); } } diff --git a/ext/pgsql/tests/09notice.phpt b/ext/pgsql/tests/09notice.phpt index 55bbd28ed1..a2955b5c52 100644 --- a/ext/pgsql/tests/09notice.phpt +++ b/ext/pgsql/tests/09notice.phpt @@ -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