change PHP errors to ErrorException in the session (PHP >=7)
Otherwise it might be that authentication apps are being disabled on during operation while in fact the session handler has hiccup. Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
05881fa4ed
commit
6f1fd9ce08
|
@ -43,12 +43,12 @@ class Internal extends Session {
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function __construct($name) {
|
public function __construct($name) {
|
||||||
session_name($name);
|
|
||||||
set_error_handler(array($this, 'trapError'));
|
set_error_handler(array($this, 'trapError'));
|
||||||
|
$this->invoke('session_name', [$name]);
|
||||||
try {
|
try {
|
||||||
session_start();
|
$this->invoke('session_start');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
setcookie(session_name(), null, -1, \OC::$WEBROOT ? : '/');
|
setcookie($this->invoke('session_name'), null, -1, \OC::$WEBROOT ?: '/');
|
||||||
}
|
}
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
if (!isset($_SESSION)) {
|
if (!isset($_SESSION)) {
|
||||||
|
@ -94,14 +94,14 @@ class Internal extends Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clear() {
|
public function clear() {
|
||||||
session_unset();
|
$this->invoke('session_unset');
|
||||||
$this->regenerateId();
|
$this->regenerateId();
|
||||||
@session_start();
|
$this->invoke('session_start', [], true);
|
||||||
$_SESSION = array();
|
$_SESSION = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function close() {
|
public function close() {
|
||||||
session_write_close();
|
$this->invoke('session_write_close');
|
||||||
parent::close();
|
parent::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ class Internal extends Session {
|
||||||
* @since 9.1.0
|
* @since 9.1.0
|
||||||
*/
|
*/
|
||||||
public function getId() {
|
public function getId() {
|
||||||
$id = @session_id();
|
$id = $this->invoke('session_id', [], true);
|
||||||
if ($id === '') {
|
if ($id === '') {
|
||||||
throw new SessionNotAvailableException();
|
throw new SessionNotAvailableException();
|
||||||
}
|
}
|
||||||
|
@ -158,4 +158,23 @@ class Internal extends Session {
|
||||||
throw new \Exception('Session has been closed - no further changes to the session are allowed');
|
throw new \Exception('Session has been closed - no further changes to the session are allowed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $functionName the full session_* function name
|
||||||
|
* @param array $parameters
|
||||||
|
* @param bool $silence whether to suppress warnings
|
||||||
|
* @throws \ErrorException via trapError
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
private function invoke($functionName, array $parameters = [], $silence = false) {
|
||||||
|
try {
|
||||||
|
if($silence) {
|
||||||
|
return @call_user_func_array($functionName, $parameters);
|
||||||
|
} else {
|
||||||
|
return call_user_func_array($functionName, $parameters);
|
||||||
|
}
|
||||||
|
} catch(\Error $e) {
|
||||||
|
$this->trapError($e->getCode(), $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue