]> granicus.if.org Git - php/commitdiff
Fix a couple of UNKNOWN default values in ext/session
authorMáté Kocsis <kocsismate@woohoolabs.com>
Mon, 22 Jun 2020 20:38:01 +0000 (22:38 +0200)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Tue, 23 Jun 2020 13:42:59 +0000 (15:42 +0200)
Closes GH-5752

ext/session/session.c
ext/session/session.stub.php
ext/session/session_arginfo.h
ext/session/tests/session_cache_limiter_error.phpt [deleted file]

index 483bf4dd0fd9ba3c68f75a5d2059151fdd5f6ef0..0b190f0496bd8030a4c797f8dd3712508af1a5f0 100644 (file)
@@ -1849,7 +1849,7 @@ PHP_FUNCTION(session_name)
        zend_string *name = NULL;
        zend_string *ini_name;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &name) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!", &name) == FAILURE) {
                RETURN_THROWS();
        }
 
@@ -1880,7 +1880,7 @@ PHP_FUNCTION(session_module_name)
        zend_string *name = NULL;
        zend_string *ini_name;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &name) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!", &name) == FAILURE) {
                RETURN_THROWS();
        }
 
@@ -2103,7 +2103,7 @@ PHP_FUNCTION(session_save_path)
        zend_string *name = NULL;
        zend_string *ini_name;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &name) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|P!", &name) == FAILURE) {
                RETURN_THROWS();
        }
 
@@ -2120,11 +2120,6 @@ PHP_FUNCTION(session_save_path)
        RETVAL_STRING(PS(save_path));
 
        if (name) {
-               if (memchr(ZSTR_VAL(name), '\0', ZSTR_LEN(name)) != NULL) {
-                       php_error_docref(NULL, E_WARNING, "The save_path cannot contain NULL characters");
-                       zval_ptr_dtor_str(return_value);
-                       RETURN_FALSE;
-               }
                ini_name = zend_string_init("session.save_path", sizeof("session.save_path") - 1, 0);
                zend_alter_ini_entry(ini_name, name, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
                zend_string_release_ex(ini_name, 0);
@@ -2139,7 +2134,7 @@ PHP_FUNCTION(session_id)
        zend_string *name = NULL;
        int argc = ZEND_NUM_ARGS();
 
-       if (zend_parse_parameters(argc, "|S", &name) == FAILURE) {
+       if (zend_parse_parameters(argc, "|S!", &name) == FAILURE) {
                RETURN_THROWS();
        }
 
@@ -2337,7 +2332,7 @@ PHP_FUNCTION(session_cache_limiter)
        zend_string *limiter = NULL;
        zend_string *ini_name;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &limiter) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!", &limiter) == FAILURE) {
                RETURN_THROWS();
        }
 
index 24942aba9b477ce33cf20bf16119d15ed9cd240a..336a35b7310e353727d06c71b3d1523e5546c6e8 100644 (file)
@@ -2,13 +2,13 @@
 
 /** @generate-function-entries */
 
-function session_name(string $name = UNKNOWN): string|false {}
+function session_name(?string $name = null): string|false {}
 
-function session_module_name(string $module = UNKNOWN): string|false {}
+function session_module_name(?string $module = null): string|false {}
 
-function session_save_path(string $path = UNKNOWN): string|false {}
+function session_save_path(?string $path = null): string|false {}
 
-function session_id(string $id = UNKNOWN): string|false {}
+function session_id(?string $id = null): string|false {}
 
 function session_create_id(string $prefix = ""): string|false {}
 
@@ -41,7 +41,7 @@ function session_commit(): bool {}
 
 function session_set_save_handler($open, $close = UNKNOWN, $read = UNKNOWN, $write = UNKNOWN, $destroy = UNKNOWN, $gc = UNKNOWN, $create_sid = UNKNOWN, $validate_sid = UNKNOWN, $update_timestamp = UNKNOWN): bool {}
 
-function session_cache_limiter(string $cache_limiter = UNKNOWN): string|false {}
+function session_cache_limiter(?string $cache_limiter = null): string|false {}
 
 function session_cache_expire(?int $new_cache_expire = null): int|false {}
 
index cae8d4fd25fa00a940e205ba4d13785d8331ea84..69f54cf851f7c70309627d863414b0ab44dc9989 100644 (file)
@@ -1,19 +1,19 @@
 /* This is a generated file, edit the .stub.php file instead. */
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_name, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
-       ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_module_name, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
-       ZEND_ARG_TYPE_INFO(0, module, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, module, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_save_path, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
-       ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, path, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_id, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
-       ZEND_ARG_TYPE_INFO(0, id, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, id, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_create_id, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
@@ -69,7 +69,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_session_set_save_handler, 0, 1,
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_cache_limiter, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
-       ZEND_ARG_TYPE_INFO(0, cache_limiter, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cache_limiter, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_cache_expire, 0, 0, MAY_BE_LONG|MAY_BE_FALSE)
diff --git a/ext/session/tests/session_cache_limiter_error.phpt b/ext/session/tests/session_cache_limiter_error.phpt
deleted file mode 100644 (file)
index d291d53..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
---TEST--
-Test session_cache_limiter() function : error functionality
---SKIPIF--
-<?php include('skipif.inc'); ?>
---FILE--
-<?php
-
-ob_start();
-
-/*
- * Prototype : string session_cache_limiter([string $cache_limiter])
- * Description : Get and/or set the current cache limiter
- * Source code : ext/session/session.c
- */
-
-echo "*** Testing session_cache_limiter() : error functionality ***\n";
-
-// Get an unset variable
-$unset_var = 10;
-unset($unset_var);
-
-class classA
-{
-    public function __toString() {
-        return "Hello World!";
-    }
-}
-
-$heredoc = <<<EOT
-Hello World!
-EOT;
-
-$fp = fopen(__FILE__, "r");
-
-// Unexpected values to be passed as arguments
-$inputs = array(
-
-       // Integer data
-/*1*/  0,
-       1,
-       12345,
-       -2345,
-
-       // Float data
-/*5*/  10.5,
-       -10.5,
-       12.3456789000e10,
-       12.3456789000E-10,
-       .5,
-
-       // Null data
-/*10*/ NULL,
-       null,
-
-       // Boolean data
-/*12*/ true,
-       false,
-       TRUE,
-       FALSE,
-
-       // Empty strings
-/*16*/ "",
-       '',
-
-       // Invalid string data
-/*18*/ "Nothing",
-       'Nothing',
-       $heredoc,
-
-       // Object data
-/*21*/ new classA(),
-
-       // Undefined data
-/*22*/ @$undefined_var,
-
-       // Unset data
-/*23*/ @$unset_var,
-);
-
-
-$iterator = 1;
-foreach($inputs as $input) {
-    echo "\n-- Iteration $iterator --\n";
-    var_dump(session_cache_limiter($input));
-    $iterator++;
-};
-
-fclose($fp);
-echo "Done";
-ob_end_flush();
-?>
---EXPECT--
-*** Testing session_cache_limiter() : error functionality ***
-
--- Iteration 1 --
-string(7) "nocache"
-
--- Iteration 2 --
-string(1) "0"
-
--- Iteration 3 --
-string(1) "1"
-
--- Iteration 4 --
-string(5) "12345"
-
--- Iteration 5 --
-string(5) "-2345"
-
--- Iteration 6 --
-string(4) "10.5"
-
--- Iteration 7 --
-string(5) "-10.5"
-
--- Iteration 8 --
-string(12) "123456789000"
-
--- Iteration 9 --
-string(13) "1.23456789E-9"
-
--- Iteration 10 --
-string(3) "0.5"
-
--- Iteration 11 --
-string(0) ""
-
--- Iteration 12 --
-string(0) ""
-
--- Iteration 13 --
-string(1) "1"
-
--- Iteration 14 --
-string(0) ""
-
--- Iteration 15 --
-string(1) "1"
-
--- Iteration 16 --
-string(0) ""
-
--- Iteration 17 --
-string(0) ""
-
--- Iteration 18 --
-string(0) ""
-
--- Iteration 19 --
-string(7) "Nothing"
-
--- Iteration 20 --
-string(7) "Nothing"
-
--- Iteration 21 --
-string(12) "Hello World!"
-
--- Iteration 22 --
-string(12) "Hello World!"
-
--- Iteration 23 --
-string(0) ""
-Done