]> granicus.if.org Git - php/commitdiff
Improved parameter handling
authorIlia Alshanetsky <iliaa@php.net>
Mon, 5 Jan 2009 16:24:14 +0000 (16:24 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 5 Jan 2009 16:24:14 +0000 (16:24 +0000)
sapi/apache/php_apache.c
sapi/apache2filter/php_functions.c
sapi/apache2handler/php_functions.c
sapi/apache_hooks/php_apache.c

index 99600fa0d5fded4ac638057d924311ca519746e0..b27085ac9659dd1bd470cd116a953a78413deaf0 100644 (file)
@@ -180,18 +180,17 @@ PHP_FUNCTION(apache_child_terminate)
    Get and set Apache request notes */
 PHP_FUNCTION(apache_note)
 {
-       char *note_name, *note_val;
+       char *note_name, *note_val = NULL;
        int note_name_len, note_val_len;
        char *old_val;
-       int arg_count = ZEND_NUM_ARGS();
 
-       if (zend_parse_parameters(arg_count TSRMLS_CC, "s|s", &note_name, &note_name_len, &note_val, &note_val_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &note_name, &note_name_len, &note_val, &note_val_len) == FAILURE) {
                return;
        }
 
        old_val = (char *) table_get(((request_rec *)SG(server_context))->notes, note_name);
 
-       if (arg_count == 2) {
+       if (note_val) {
                table_set(((request_rec *)SG(server_context))->notes, note_name, note_val);
        }
 
index 85f477f8719c15d6e19d05c8b08a68a4e8c3a674..289f386c1408d93234a6a2b4c105282030ac1c31 100644 (file)
@@ -193,12 +193,11 @@ PHP_FUNCTION(apache_response_headers)
 PHP_FUNCTION(apache_note)
 {
        php_struct *ctx;
-       char *note_name, *note_val;
+       char *note_name, *note_val = NULL;
        int note_name_len, note_val_len;
        char *old_note_val=NULL;
-       int arg_count = ZEND_NUM_ARGS();
 
-       if (zend_parse_parameters(arg_count TSRMLS_CC, "s|s", &note_name, &note_name_len, &note_val, &note_val_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &note_name, &note_name_len, &note_val, &note_val_len) == FAILURE) {
                return;
        }
 
@@ -206,7 +205,7 @@ PHP_FUNCTION(apache_note)
 
        old_note_val = (char *) apr_table_get(ctx->r->notes, note_name);
 
-       if (arg_count == 2) {
+       if (note_val) {
                apr_table_set(ctx->r->notes, note_name, note_val);
        }
 
index db640434029108baa9b5f676cc1f93dd04961634..e7dd7fed1b647211bb62843700cbcb4224eabe19 100644 (file)
@@ -221,12 +221,11 @@ PHP_FUNCTION(apache_response_headers)
 PHP_FUNCTION(apache_note)
 {
        php_struct *ctx;
-       char *note_name, *note_val;
+       char *note_name, *note_val = NULL;
        int note_name_len, note_val_len;
        char *old_note_val=NULL;
-       int arg_count = ZEND_NUM_ARGS();
 
-       if (zend_parse_parameters(arg_count TSRMLS_CC, "s|s", &note_name, &note_name_len, &note_val, &note_val_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &note_name, &note_name_len, &note_val, &note_val_len) == FAILURE) {
                return;
        }
 
@@ -234,7 +233,7 @@ PHP_FUNCTION(apache_note)
 
        old_note_val = (char *) apr_table_get(ctx->r->notes, note_name);
 
-       if (arg_count == 2) {
+       if (note_val) {
                apr_table_set(ctx->r->notes, note_name, note_val);
        }
 
index 77c0e0e8d96ccc0fec840e0eeb5250083007e39d..4ee6e1529f9ea54be1d1569bfa0384c3a4eb6abc 100644 (file)
@@ -1551,18 +1551,17 @@ PHP_FUNCTION(apache_child_terminate)
    Get and set Apache request notes */
 PHP_FUNCTION(apache_note)
 {
-       char *arg_name, *arg_val;
+       char *arg_name, *arg_val = NULL;
        int arg_name_len, arg_val_len;
        char *note_val;
-       int arg_count = ZEND_NUM_ARGS();
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &arg_name, &arg_name_len, &arg_val, &arg_val_len) == FAILURE) {
                return;
        }
 
        note_val = (char *) table_get(((request_rec *)SG(server_context))->notes, arg_name);
-       
-       if (arg_count == 2) {
+
+       if (arg_val) {
                table_set(((request_rec *)SG(server_context))->notes, arg_name, arg_val);
        }