Use Native Session functions (global "$_SESSION" variable) for Memory class because of the direct usage of the $_SESSION class all around the codebase

This commit is contained in:
nupplaPhil 2019-12-10 22:29:49 +01:00
parent eca3396851
commit b9f8762eb3
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
4 changed files with 13 additions and 73 deletions

View file

@ -4,11 +4,11 @@ namespace Friendica\Core\Session;
/**
* Usable for backend processes (daemon/worker) and testing
*
* @todo after replacing the last direct $_SESSION call, use a internal array instead of the global variable
*/
final class Memory implements ISession
final class Memory extends Native
{
private $data = [];
public function start()
{
// Backward compatibility until all Session variables are replaced
@ -17,69 +17,4 @@ final class Memory implements ISession
$this->clear();
return $this;
}
/**
* @inheritDoc
*/
public function exists(string $name)
{
return isset($this->data[$name]);
}
/**
* @inheritDoc
*/
public function get(string $name, $defaults = null)
{
return $this->data[$name] ?? $defaults;
}
/**
* @inheritDoc
*/
public function set(string $name, $value)
{
$this->data[$name] = $value;
}
/**
* @inheritDoc
*/
public function setMultiple(array $values)
{
foreach ($values as $key => $value) {
$this->data[$key] = $value;
}
}
/**
* @inheritDoc
*/
public function remove(string $name)
{
if ($this->exists($name)) {
unset($this->data[$name]);
return true;
}
return false;
}
/**
* @inheritDoc
*/
public function clear()
{
$this->data = [];
return true;
}
/**
* @inheritDoc
*/
public function delete()
{
$this->data = [];
return true;
}
}
}