Cm_RedisSession icon indicating copy to clipboard operation
Cm_RedisSession copied to clipboard

Make setSaveHandler() only callable once

Open joshua-bn opened this issue 4 years ago • 0 comments

Running EcomDev_PhpUnit with E_ALL on PHP 7.4 (modified version of OpenMage) and my tests are complaining with this error:

Error: Warning: session_set_save_handler(): Cannot change save handler when headers already sent  in app/code/community/Cm/RedisSession/Model/Session.php on line 51

That's setSaveHandler() being called multiple times. I changed this locally by just putting the call in the constructor. Since it never gets created outside of the getResourceSingleton() calls, this works. Since this repo doesn't have control over those areas, it could instead set a property and check that: private $isSessionSaveHandlerSet = false and then check if it is true/false in the setSaveHandler() method. If it is already set, do nothing.

joshua-bn avatar Jan 05 '21 16:01 joshua-bn