mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
MFH: fix putenv("var") (i.e. unset) on BSD systems
add test
This commit is contained in:
parent
695e81c2cc
commit
16129b7024
2 changed files with 36 additions and 1 deletions
|
@ -4462,7 +4462,14 @@ PHP_FUNCTION(putenv)
|
|||
SetEnvironmentVariable(pe.key, "bugbug");
|
||||
#endif
|
||||
|
||||
#if HAVE_UNSETENV
|
||||
if (!p) { /* no '=' means we want to unset it */
|
||||
unsetenv(pe.putenv_string);
|
||||
}
|
||||
if (!p || putenv(pe.putenv_string) == 0) { /* success */
|
||||
#else
|
||||
if (putenv(pe.putenv_string) == 0) { /* success */
|
||||
#endif
|
||||
zend_hash_add(&BG(putenv_ht), pe.key, pe.key_len+1, (void **) &pe, sizeof(putenv_entry), NULL);
|
||||
#ifdef HAVE_TZSET
|
||||
if (!strncmp(pe.key, "TZ", pe.key_len)) {
|
||||
|
|
28
ext/standard/tests/general_functions/putenv.phpt
Normal file
28
ext/standard/tests/general_functions/putenv.phpt
Normal file
|
@ -0,0 +1,28 @@
|
|||
--TEST--
|
||||
putenv() basic tests
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$var_name="SUCHVARSHOULDNOTEXIST";
|
||||
|
||||
var_dump(getenv($var_name));
|
||||
var_dump(putenv($var_name."=value"));
|
||||
var_dump(getenv($var_name));
|
||||
|
||||
var_dump(putenv($var_name."="));
|
||||
var_dump(getenv($var_name));
|
||||
|
||||
var_dump(putenv($var_name));
|
||||
var_dump(getenv($var_name));
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(false)
|
||||
bool(true)
|
||||
string(5) "value"
|
||||
bool(true)
|
||||
string(0) ""
|
||||
bool(true)
|
||||
bool(false)
|
||||
Done
|
Loading…
Add table
Add a link
Reference in a new issue