Bug #75628 [Com]: session_set_save_handler() prints warnings in a unit test

From: Date: Thu, 31 May 2018 15:12:31 +0000
Subject: Bug #75628 [Com]: session_set_save_handler() prints warnings in a unit test
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215455@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75628&edit=1

 ID:                 75628
 Comment by:         jeroen at asystance dot nl
 Reported by:        damyon at moodle dot com
 Summary:            session_set_save_handler() prints warnings in a unit
                     test
 Status:             Open
 Type:               Bug
 Package:            Session related
 Operating System:   Linux Mint 17.3 Rosa
 PHP Version:        7.2.0
 Block user comment: N
 Private report:     N

 New Comment:

Confirmed in version 7.2.5.


Previous Comments:
------------------------------------------------------------------------
[2018-01-23 09:27:02] matteo dot scaramuccia at gmail dot com

Hello,
is there any dev progress here?
Still relevant in 7.2.1 too.

TIA,
Matteo

------------------------------------------------------------------------
[2017-12-05 08:48:07] damyon at moodle dot com

Sorry the test script has "S>" lines in it (copy / paste problem).

------------------------------------------------------------------------
[2017-12-05 08:38:34] damyon at moodle dot com

Description:
------------
When unit testing session-related code in a CLI environment, appropriate PHP ini settings combined
with passing false to session_cache_limiter should allow the session handler to be changed even if
output has been already sent.

With PHP 7.2.0RC5 calling session_set_save_handler prints warning messages, regardless of php ini
settings.

Very similar previously fixed bug:

https://bugs.php.net/bug.php?id=55267

Very similar (but not the same) bugs with php 7.2

https://bugs.php.net/bug.php?id=74936
https://bugs.php.net/bug.php?id=74514

Test script:
---------------
<?php                                                                                            
                                  
S>                                                                                               
S>                                     
  ini_set('session.use_cookies', false);                                                  
                                           
  ini_set('session.use_only_cookies', false);                                             
                                           
  ini_set('session.use_trans_id', 1);                                                     
                                           
  ini_set('session.cache_limiter', false);                                                
                                           
  session_cache_limiter(false);                                                                     
                                 
                                                                                                    
                                 
  echo '.';                                                                               
                                           
                                                                                                    
                                 
  class MySessionHandler extends SessionHandler                                                     
                                 
  {                                                                                                 
                                 
S>                                                                                               
S>                                     
  }                                                                                                 
                                 
                                                                                                    
                                 
  $handler = new MySessionHandler();                                                                
                                 
  session_set_save_handler($handler, true);

Expected result:
----------------
One single dot of output

Actual result:
--------------
.PHP Warning:  session_set_save_handler(): Cannot change save handler when headers already sent in
[filepath]/test.php on line 17



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=75628&edit=1


Thread (10 messages)

« previous php.bugs (#215455) next »