]> granicus.if.org Git - php/commitdiff
use & and check for the right value of result_type
authorAntony Dovgal <tony2001@php.net>
Tue, 10 May 2005 23:15:06 +0000 (23:15 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 10 May 2005 23:15:06 +0000 (23:15 +0000)
btw, nobody noticed that result_type wasn't ever working in 4.3, because it was absent in parse_params()..
also, I prefer "Tony" just for uniformity =)

NEWS
ext/pgsql/pgsql.c

diff --git a/NEWS b/NEWS
index f8a5f16a75f9e4ebb71f7b3b3f38a69beb8abd9f..267bcb9afd358f2b494c8f282ce432140ca4bb6b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,7 +10,7 @@ PHP 4                                                                      NEWS
 - Fixed bug #32974 (pcntl calls malloc() from a signal handler). (Wez)
 - Fixed bug #32936 (http redirects URLs are not checked for control chars). (Ilia)
 - Fixed bug #32932 (Oracle LDAP: ldap_get_entries invalid pointer). (Jani)
-- Fixed bug #32904 (pg_get_notify() ignores result_type parameter). (Antony)
+- Fixed bug #32904 (pg_get_notify() ignores result_type parameter). (Tony)
 - Fixed bug #32813 (parse_url() does not handle scheme-only urls properly). (Ilia)
 - Fixed bug #32802 (General cookie overrides more specific cookie). (Ilia)
 - Fixed bugs #32800, #32830 (ext/odbc: Problems with 64bit systems). (Jani)
index ca63c43d871ef8e7570db5c24a94e0277154a532..41a50ea40f3900e3cf952e273c14db3e426632ca 100644 (file)
@@ -3125,12 +3125,17 @@ PHP_FUNCTION(pg_get_notify)
        PGnotify *pgsql_notify;
 
        if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "r|l",
-                                                                &pgsql_link) == FAILURE) {
+                                                                &pgsql_link, &result_type) == FAILURE) {
                RETURN_FALSE;
        }
 
        ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
 
+       if (!(result_type & PGSQL_BOTH)) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid result type");
+               RETURN_FALSE;
+       }
+
        PQconsumeInput(pgsql);
        pgsql_notify = PQnotifies(pgsql);
        if (!pgsql_notify) {
@@ -3138,11 +3143,11 @@ PHP_FUNCTION(pg_get_notify)
                RETURN_FALSE;
        }
        array_init(return_value);
-       if (result_type == PGSQL_NUM || result_type == PGSQL_BOTH) {
+       if (result_type & PGSQL_NUM) {
                add_index_string(return_value, 0, pgsql_notify->relname, 1);
                add_index_long(return_value, 1, pgsql_notify->be_pid);
        }
-       if (result_type == PGSQL_ASSOC || result_type == PGSQL_BOTH) {
+       if (result_type & PGSQL_ASSOC) {
                add_assoc_string(return_value, "message", pgsql_notify->relname, 1);
                add_assoc_long(return_value, "pid", pgsql_notify->be_pid);
        }