php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
mod_user_class.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: Arpad Ray <arpad@php.net> |
14 +----------------------------------------------------------------------+
15 */
16
17#include "php.h"
18#include "php_session.h"
19
20#define PS_SANITY_CHECK \
21 if (PS(session_status) != php_session_active) { \
22 zend_throw_error(NULL, "Session is not active"); \
23 RETURN_THROWS(); \
24 } \
25 if (PS(default_mod) == NULL) { \
26 zend_throw_error(NULL, "Cannot call default session handler"); \
27 RETURN_THROWS(); \
28 }
29
30#define PS_SANITY_CHECK_IS_OPEN \
31 PS_SANITY_CHECK; \
32 if (!PS(mod_user_is_open)) { \
33 php_error_docref(NULL, E_WARNING, "Parent session handler is not open"); \
34 RETURN_FALSE; \
35 }
36
37/* {{{ Wraps the old open handler */
39{
40 char *save_path = NULL, *session_name = NULL;
41 size_t save_path_len, session_name_len;
43
44 if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &save_path, &save_path_len, &session_name, &session_name_len) == FAILURE) {
46 }
47
49
50 zend_try {
51 ret = PS(default_mod)->s_open(&PS(mod_data), save_path, session_name);
52 } zend_catch {
55 } zend_end_try();
56
57 if (SUCCESS == ret) {
58 PS(mod_user_is_open) = 1;
59 }
60
62}
63/* }}} */
64
65/* {{{ Wraps the old close handler */
67{
69
70 // don't return on failure, since not closing the default handler
71 // could result in memory leaks or other nasties
73
75
76 PS(mod_user_is_open) = 0;
77
78 zend_try {
79 ret = PS(default_mod)->s_close(&PS(mod_data));
80 } zend_catch {
83 } zend_end_try();
84
86}
87/* }}} */
88
89/* {{{ Wraps the old read handler */
91{
94
97 }
98
100
101 if (PS(default_mod)->s_read(&PS(mod_data), key, &val, PS(gc_maxlifetime)) == FAILURE) {
103 }
104
106}
107/* }}} */
108
109/* {{{ Wraps the old write handler */
111{
113
114 if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS", &key, &val) == FAILURE) {
116 }
117
119
120 RETURN_BOOL(SUCCESS == PS(default_mod)->s_write(&PS(mod_data), key, val, PS(gc_maxlifetime)));
121}
122/* }}} */
123
124/* {{{ Wraps the old destroy handler */
126{
128
131 }
132
134
135 RETURN_BOOL(SUCCESS == PS(default_mod)->s_destroy(&PS(mod_data), key));
136}
137/* }}} */
138
139/* {{{ Wraps the old gc handler */
141{
142 zend_long maxlifetime;
143 zend_long nrdels = -1;
144
145 if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &maxlifetime) == FAILURE) {
147 }
148
150
151 if (PS(default_mod)->s_gc(&PS(mod_data), maxlifetime, &nrdels) == FAILURE) {
153 }
154 RETURN_LONG(nrdels);
155}
156/* }}} */
157
158/* {{{ Wraps the old create_sid handler */
160{
161 zend_string *id;
162
165 }
166
168
169 id = PS(default_mod)->s_create_sid(&PS(mod_data));
170
171 RETURN_STR(id);
172}
173/* }}} */
zval * val
Definition ffi.c:4262
#define NULL
Definition gdcache.h:45
#define SUCCESS
Definition hash_sha3.c:261
#define PS_SANITY_CHECK_IS_OPEN
#define PS_SANITY_CHECK
#define PHP_METHOD
Definition php.h:365
unsigned char key[REFLECTION_KEY_LEN]
@ php_session_none
#define PS(v)
session_name(?string $name=null)
session_status()
#define close(a)
#define zend_catch
Definition zend.h:277
#define zend_try
Definition zend.h:270
#define zend_end_try()
Definition zend.h:280
#define zend_bailout()
Definition zend.h:268
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
Definition zend_API.c:1300
#define ZEND_NUM_ARGS()
Definition zend_API.h:530
#define RETURN_FALSE
Definition zend_API.h:1058
#define zend_parse_parameters_none()
Definition zend_API.h:353
#define RETURN_LONG(l)
Definition zend_API.h:1037
#define RETURN_BOOL(b)
Definition zend_API.h:1035
#define RETURN_THROWS()
Definition zend_API.h:1060
#define RETURN_STR(s)
Definition zend_API.h:1039
int32_t zend_long
Definition zend_long.h:42
struct _zend_string zend_string
@ FAILURE
Definition zend_types.h:61
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
zval * ret