Skip to content

Commit 2f10e9a

Browse files
committed
added test and added global to be null
1 parent 90cde42 commit 2f10e9a

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/appserver.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,12 @@ PHP_FUNCTION(appserver_session_init)
355355
PS(mod_user_is_open) = 0;
356356
/* Do NOT init PS(mod_user_names) here! */
357357
PS(http_session_vars) = NULL;
358+
359+
/* update SESSION global and set it NULL */
360+
zval *nullVal;
361+
ALLOC_INIT_ZVAL(nullVal);
362+
Z_TYPE_P(nullVal) = IS_NULL;
363+
zend_hash_update(&EG(symbol_table), "_SESSION", strlen("_SESSION") + 1, &nullVal, sizeof(zval *), NULL);
358364
}
359365

360366
/* {{{ proto boolean appserver_redefine(string $constant [, mixed $value])

src/tests/appserver_013.phpt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
appserver: call appserver_session_init and check if session env was reset properly
3+
--CREDITS--
4+
Johann Zelger <jz [at] techdivision [dot] com>
5+
--INI--
6+
error_reporting = E_ERROR
7+
--FILE--
8+
<?php
9+
$initSessionStatus = var_export(session_status(), true);
10+
$initSessionGlobal = var_export($_SESSION, true);
11+
session_start();
12+
13+
$_SESSION['test-key'] = 'test-value';
14+
var_dump($_SESSION);
15+
var_dump(session_status());
16+
17+
session_write_close();
18+
var_dump($_SESSION);
19+
var_dump(session_status());
20+
21+
appserver_session_init();
22+
echo var_export(session_status(), true) . "\r\n";
23+
echo var_export($_SESSION, true) . "\r\n";
24+
25+
echo $initSessionStatus . "\r\n";
26+
echo $initSessionGlobal . "\r\n";
27+
--EXPECT--
28+
array(1) {
29+
["test-key"]=>
30+
string(10) "test-value"
31+
}
32+
int(2)
33+
array(1) {
34+
["test-key"]=>
35+
string(10) "test-value"
36+
}
37+
int(1)
38+
1
39+
NULL
40+
1
41+
NULL

0 commit comments

Comments
 (0)