php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75628 session_set_save_handler() prints warnings in a unit test
Submitted: 2017-12-05 08:38 UTC Modified: 2017-12-05 08:48 UTC
Votes:14
Avg. Score:4.4 ± 0.9
Reproduced:13 of 13 (100.0%)
Same Version:10 (76.9%)
Same OS:2 (15.4%)
From: damyon at moodle dot com Assigned:
Status: Open Package: Session related
PHP Version: 7.2.0 OS: Linux Mint 17.3 Rosa
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-12-05 08:38 UTC] 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>                                                                                                                                    
  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>                                                                                                                                    
  }                                                                                                                                   
                                                                                                                                      
  $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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-05 08:48 UTC] damyon at moodle dot com
Sorry the test script has "S>" lines in it (copy / paste problem).
 [2018-01-23 09:27 UTC] matteo dot scaramuccia at gmail dot com
Hello,
is there any dev progress here?
Still relevant in 7.2.1 too.

TIA,
Matteo
 [2018-05-31 15:12 UTC] jeroen at asystance dot nl
Confirmed in version 7.2.5.
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Thu Jul 19 17:01:25 2018 UTC