Restructure Session to follow new paradigm

This commit is contained in:
Philipp 2021-10-23 11:39:29 +02:00
parent ff1a812e1a
commit 57b4c008cb
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
7 changed files with 13 additions and 11 deletions

View file

@ -19,14 +19,13 @@
* *
*/ */
namespace Friendica\Factory; namespace Friendica\Core\Session\Factory;
use Friendica\App; use Friendica\App;
use Friendica\Core\Cache\ICache; use Friendica\Core\Cache\ICache;
use Friendica\Core\Cache\Enum\Type; use Friendica\Core\Cache\Enum\Type;
use Friendica\Core\Config\IConfig; use Friendica\Core\Config\IConfig;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -63,7 +62,7 @@ class SessionFactory
try { try {
if ($mode->isInstall() || $mode->isBackend()) { if ($mode->isInstall() || $mode->isBackend()) {
$session = new Session\Memory(); $session = new Session\Type\Memory();
} else { } else {
$session_handler = $config->get('system', 'session_handler', self::HANDLER_DEFAULT); $session_handler = $config->get('system', 'session_handler', self::HANDLER_DEFAULT);
$handler = null; $handler = null;
@ -82,7 +81,7 @@ class SessionFactory
break; break;
} }
$session = new Session\Native($baseURL, $handler); $session = new Session\Type\Native($baseURL, $handler);
} }
} finally { } finally {
$profiler->stopRecording(); $profiler->stopRecording();

View file

@ -19,7 +19,7 @@
* *
*/ */
namespace Friendica\Core\Session; namespace Friendica\Core\Session\Type;
/** /**
* Contains the base methods for $_SESSION interaction * Contains the base methods for $_SESSION interaction

View file

@ -19,7 +19,9 @@
* *
*/ */
namespace Friendica\Core\Session; namespace Friendica\Core\Session\Type;
use Friendica\Core\Session\ISession;
/** /**
* Usable for backend processes (daemon/worker) and testing * Usable for backend processes (daemon/worker) and testing

View file

@ -19,9 +19,10 @@
* *
*/ */
namespace Friendica\Core\Session; namespace Friendica\Core\Session\Type;
use Friendica\App; use Friendica\App;
use Friendica\Core\Session\ISession;
use Friendica\Model\User\Cookie; use Friendica\Model\User\Cookie;
use SessionHandlerInterface; use SessionHandlerInterface;

View file

@ -207,7 +207,7 @@ return [
], ],
], ],
ISession::class => [ ISession::class => [
'instanceOf' => Factory\SessionFactory::class, 'instanceOf' => \Friendica\Core\Session\Factory\SessionFactory::class,
'call' => [ 'call' => [
['createSession', [$_SERVER], Dice::CHAIN_CALL], ['createSession', [$_SERVER], Dice::CHAIN_CALL],
['start', [], Dice::CHAIN_CALL], ['start', [], Dice::CHAIN_CALL],

View file

@ -33,7 +33,7 @@ abstract class FixtureTest extends DatabaseTest
$this->dice = (new Dice()) $this->dice = (new Dice())
->addRules(include __DIR__ . '/../static/dependencies.config.php') ->addRules(include __DIR__ . '/../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]) ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
->addRule(ISession::class, ['instanceOf' => Session\Memory::class, 'shared' => true, 'call' => null]); ->addRule(ISession::class, ['instanceOf' => Session\Type\Memory::class, 'shared' => true, 'call' => null]);
DI::init($this->dice); DI::init($this->dice);
/** @var IConfig $config */ /** @var IConfig $config */

View file

@ -253,7 +253,7 @@ class StorageManagerTest extends DatabaseTest
$dice = (new Dice()) $dice = (new Dice())
->addRules(include __DIR__ . '/../../../static/dependencies.config.php') ->addRules(include __DIR__ . '/../../../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]) ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
->addRule(ISession::class, ['instanceOf' => Session\Memory::class, 'shared' => true, 'call' => null]); ->addRule(ISession::class, ['instanceOf' => Session\Type\Memory::class, 'shared' => true, 'call' => null]);
DI::init($dice); DI::init($dice);
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n); $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
@ -281,7 +281,7 @@ class StorageManagerTest extends DatabaseTest
$dice = (new Dice()) $dice = (new Dice())
->addRules(include __DIR__ . '/../../../static/dependencies.config.php') ->addRules(include __DIR__ . '/../../../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]) ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
->addRule(ISession::class, ['instanceOf' => Session\Memory::class, 'shared' => true, 'call' => null]); ->addRule(ISession::class, ['instanceOf' => Session\Type\Memory::class, 'shared' => true, 'call' => null]);
DI::init($dice); DI::init($dice);
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n); $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);