diff --git a/phpgwapi/inc/class.egw_session_memcache.inc.php b/phpgwapi/inc/class.egw_session_memcache.inc.php index 0bd6632d64..936545f610 100644 --- a/phpgwapi/inc/class.egw_session_memcache.inc.php +++ b/phpgwapi/inc/class.egw_session_memcache.inc.php @@ -57,17 +57,6 @@ class egw_session_memcache { self::$mbstring_func_overload = @extension_loaded('mbstring') && (ini_get('mbstring.func_overload') & 2); - if (version_compare(PHP_VERSION,'5.2','>=')) - { - $ret = session_set_save_handler( - array(__CLASS__,'open'), - array(__CLASS__,'close'), - array(__CLASS__,'read'), - array(__CLASS__,'write'), - array(__CLASS__,'destroy'), - array(__CLASS__,'gc')); - if (!$ret) error_log(__METHOD__.'() session_set_save_handler(...)='.(int)$ret.', session_module_name()='.session_module_name().' *******************************'); - } // session needs to be closed before objects get destroyed, as this session-handler is an object ;-) register_shutdown_function('session_write_close'); } @@ -81,6 +70,10 @@ class egw_session_memcache */ public static function open($save_path, $session_name) { + if (!extension_loaded('memcache') && !dl(PHP_SHLIB_PREFIX.'memcache.'.PHP_SHLIB_SUFFIX)) + { + throw new Exception("Required PHP extension 'memcache' not loaded AND can NOT be loaded!"); + } self::$memcache = new Memcache; foreach(explode(',',$save_path) as $path) { @@ -270,19 +263,16 @@ class egw_session_memcache } } -if (version_compare(PHP_VERSION,'5.2','<')) +function init_session_handler() { - function init_session_handler() - { - $ses = 'egw_session_memcache'; - $ret = session_set_save_handler( - array($ses,'open'), - array($ses,'close'), - array($ses,'read'), - array($ses,'write'), - array($ses,'destroy'), - array($ses,'gc')); - if (!$ret) error_log(__METHOD__.'() session_set_save_handler(...)='.(int)$ret.', session_module_name()='.session_module_name().' *******************************'); - } - init_session_handler(); + $ses = 'egw_session_memcache'; + $ret = session_set_save_handler( + array($ses,'open'), + array($ses,'close'), + array($ses,'read'), + array($ses,'write'), + array($ses,'destroy'), + array($ses,'gc')); + if (!$ret) error_log(__METHOD__.'() session_set_save_handler(...)='.(int)$ret.', session_module_name()='.session_module_name().' *******************************'); } +init_session_handler(); \ No newline at end of file