File tree 2 files changed +29
-8
lines changed
2 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -247,10 +247,7 @@ static void php_session_track_init(void) /* {{{ */
247
247
static zend_string * php_session_encode (void ) /* {{{ */
248
248
{
249
249
IF_SESSION_VARS () {
250
- if (!PS (serializer )) {
251
- php_error_docref (NULL , E_WARNING , "Unknown session.serialize_handler. Failed to encode session object" );
252
- return NULL ;
253
- }
250
+ ZEND_ASSERT (PS (serializer ));
254
251
return PS (serializer )-> encode ();
255
252
} else {
256
253
php_error_docref (NULL , E_WARNING , "Cannot encode non-existent session" );
@@ -268,10 +265,7 @@ static ZEND_COLD void php_session_cancel_decode(void)
268
265
269
266
static zend_result php_session_decode (zend_string * data ) /* {{{ */
270
267
{
271
- if (!PS (serializer )) {
272
- php_error_docref (NULL , E_WARNING , "Unknown session.serialize_handler. Failed to decode session object" );
273
- return FAILURE ;
274
- }
268
+ ZEND_ASSERT (PS (serializer ));
275
269
zend_result result = SUCCESS ;
276
270
zend_try {
277
271
if (PS (serializer )-> decode (ZSTR_VAL (data ), ZSTR_LEN (data )) == FAILURE ) {
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Test session_decode() function : error functionality
3
+ --EXTENSIONS--
4
+ session
5
+ --SKIPIF--
6
+ <?php include ('skipif.inc ' ); ?>
7
+ --INI--
8
+ session.serialize_handler = wrong_handler
9
+ --FILE--
10
+ <?php
11
+
12
+ ob_start ();
13
+ session_start ();
14
+ ini_set ('session.serialize_handler ' , 'wrong_handler ' );
15
+ var_dump (session_decode ('' ));
16
+
17
+ echo "Done " ;
18
+ ob_end_flush ();
19
+ ?>
20
+ --EXPECTF--
21
+ Warning: session_start(): Cannot find session serialization handler "wrong_handler" - session startup failed in %s on line 4
22
+
23
+ Warning: ini_set(): Serialization handler "wrong_handler" cannot be found in %s on line 5
24
+
25
+ Warning: session_decode(): Session data cannot be decoded when there is no active session in %s on line 6
26
+ bool(false)
27
+ Done
You can’t perform that action at this time.
0 commit comments