@@ -51,13 +51,13 @@ protected function getSerializers() {
5151 }
5252
5353protected function getCompressors () {
54- $ result [] = Redis::COMPRESSION_NONE ;
54+ $ result [' none ' ] = Redis::COMPRESSION_NONE ;
5555if (defined ('Redis::COMPRESSION_LZF ' ))
56- $ result [] = Redis::COMPRESSION_LZF ;
56+ $ result [' lzf ' ] = Redis::COMPRESSION_LZF ;
5757if (defined ('Redis::COMPRESSION_LZ4 ' ))
58- $ result [] = Redis::COMPRESSION_LZ4 ;
58+ $ result [' lz4 ' ] = Redis::COMPRESSION_LZ4 ;
5959if (defined ('Redis::COMPRESSION_ZSTD ' ))
60- $ result [] = Redis::COMPRESSION_ZSTD ;
60+ $ result [' zstd ' ] = Redis::COMPRESSION_ZSTD ;
6161
6262return $ result ;
6363 }
@@ -7377,6 +7377,26 @@ public function testHighPorts() {
73777377 }
73787378 }
73797379
7380+ public function testSession_compression () {
7381+ $ this ->setSessionHandler ();
7382+
7383+ foreach ($ this ->getCompressors ()as $ name =>$ val ) {
7384+
7385+ $ id =$ this ->generateSessionId ();
7386+ $ res =$ this ->startSessionProcess ($ id ,0 ,false ,300 ,true ,null ,
7387+ -1 ,0 ,"testing_compression_ $ name " ,1440 ,
7388+ $ name );
7389+
7390+ $ this ->assertTrue ($ res );
7391+
7392+ $ key =$ this ->sessionPrefix .$ id ;
7393+
7394+ $ this ->redis ->setOption (Redis::OPT_COMPRESSION ,$ val );
7395+ $ this ->assertTrue ($ this ->redis ->get ($ key ) !==false );
7396+ $ this ->redis ->setOption (Redis::OPT_COMPRESSION , Redis::COMPRESSION_NONE );
7397+ }
7398+ }
7399+
73807400public function testSession_savedToRedis ()
73817401 {
73827402$ this ->setSessionHandler ();
@@ -7878,33 +7898,40 @@ private function generateSessionId()
78787898 * @param int $lock_retries
78797899 * @param int $lock_expires
78807900 * @param string $sessionData
7881- *
78827901 * @param int $sessionLifetime
7902+ * @param string $sessionCompression
78837903 *
78847904 * @return bool
78857905 * @throws Exception
78867906 */
7887- private function startSessionProcess ($ sessionId ,$ sleepTime ,$ background ,$ maxExecutionTime =300 ,$ locking_enabled =true ,$ lock_wait_time =null ,$ lock_retries = -1 ,$ lock_expires =0 ,$ sessionData ='' ,$ sessionLifetime =1440 )
7907+ private function startSessionProcess ($ sessionId ,$ sleepTime ,$ background ,
7908+ $ maxExecutionTime =300 ,
7909+ $ locking_enabled =true ,
7910+ $ lock_wait_time =null ,
7911+ $ lock_retries = -1 ,
7912+ $ lock_expires =0 ,
7913+ $ sessionData ='' ,
7914+ $ sessionLifetime =1440 ,
7915+ $ sessionCompression ='none ' )
78887916 {
7889- if (substr (php_uname (),0 , 7 ) ==" Windows " ){
7917+ if (strpos (php_uname (),' Windows ' ) ! ==false )
78907918$ this ->markTestSkipped ();
7891- return true ;
7892- }else {
7893- $ commandParameters = [$ this ->getFullHostPath (),$ this ->sessionSaveHandler ,$ sessionId ,$ sleepTime ,$ maxExecutionTime ,$ lock_retries ,$ lock_expires ,$ sessionData ,$ sessionLifetime ];
7894- if ($ locking_enabled ) {
7895- $ commandParameters [] ='1 ' ;
78967919
7897- if ($ lock_wait_time !=null ) {
7898- $ commandParameters [] =$ lock_wait_time ;
7899- }
7900- }
7901- $ commandParameters =array_map ('escapeshellarg ' ,$ commandParameters );
7920+ $ commandParameters = [
7921+ $ this ->getFullHostPath (),$ this ->sessionSaveHandler ,$ sessionId ,
7922+ $ sleepTime ,$ maxExecutionTime ,$ lock_retries ,$ lock_expires ,
7923+ $ sessionData ,$ sessionLifetime ,$ locking_enabled ?1 :0 ,
7924+ $ lock_wait_time ??0 ,$ sessionCompression
7925+ ];
79027926
7903- $ command =self ::getPhpCommand ('startSession.php ' ) .implode (' ' ,$ commandParameters );
7904- $ command .=$ background ?' 2>/dev/null > /dev/null & ' :' 2>&1 ' ;
7905- exec ($ command ,$ output );
7906- return ($ background || (count ($ output ) ==1 &&$ output [0 ] =='SUCCESS ' )) ?true :false ;
7907- }
7927+ $ commandParameters =array_map ('escapeshellarg ' ,$ commandParameters );
7928+ $ commandParameters [] =$ background ?'>/dev/null 2>&1 & ' :'2>&1 ' ;
7929+
7930+ $ command =self ::getPhpCommand ('startSession.php ' ) .implode (' ' ,$ commandParameters );
7931+
7932+ exec ($ command ,$ output );
7933+
7934+ return ($ background || (count ($ output ) ==1 &&$ output [0 ] =='SUCCESS ' ));
79087935 }
79097936
79107937/**