mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix a couple of UNKNOWN default values in ext/session
Closes GH-5752
This commit is contained in:
parent
35729b7604
commit
b981662855
4 changed files with 15 additions and 183 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue