Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
12090ca
WIP: Adjust Neos.Utility.Unicode
Apr 4, 2025
197f785
Adjust Neos.Utility.Schema
Apr 4, 2025
8b352e5
Adjust Neos.Utility.Pdo
Apr 4, 2025
55a382d
Adjust Neos.Utility.ObjectHandling
Apr 4, 2025
7b5ffb1
Adjust Neos.Utility.MediaTypes
Apr 4, 2025
c4e0b30
Adjust Neos.Utility.Files
Apr 4, 2025
a2a0cb5
Adjust Neos.Utility.Arrays
Apr 4, 2025
0ed0d3b
Adjust Neos.Kickstarter
Apr 5, 2025
8a68997
Adjust Neos.Http.Factories
Apr 5, 2025
00cdf82
Adjust Neos.Http.Factories
Apr 5, 2025
44ff551
Adjust Neos.FluidAdaptor
Apr 5, 2025
ce6556a
Adjust Neos.Flow.Log
Apr 5, 2025
825afdd
Adjust Neos.Flow Validation subcontext
Apr 6, 2025
faf233d
Adjust Neos.Flow Utility subcontext
Apr 6, 2025
a2ade03
Adjust Neos.Flow SignalSlot subcontext
Apr 6, 2025
f6dd082
Adjust Neos.Flow Session subcontext
Apr 6, 2025
60afee3
Adjust Neos.Flow Security subcontext
Apr 6, 2025
a583cc3
Adjust Neos.Flow ResourceManagement subcontext
Apr 6, 2025
0970fbb
Adjust Neos.Flow Reflection subcontext
Apr 7, 2025
b7ef78a
Adjust Neos.Flow Property subcontext
Apr 7, 2025
d8efec8
Adjust Neos.Flow Persistence subcontext
Apr 8, 2025
bbb9bf7
Adjust Neos.Flow Package subcontext
Apr 8, 2025
6eccf33
Adjust Neos.Flow ObjectManagement subcontext
Apr 10, 2025
f0d2343
Adjust Neos.Flow Mvc subcontext
Apr 10, 2025
2042edc
Adjust Neos.Flow Monitor subcontext
Apr 11, 2025
a2d5d86
Adjust Neos.Flow Log subcontext
Apr 11, 2025
2076a93
Adjust Neos.Flow I18n subcontext
Apr 11, 2025
a2e021c
Adjust Neos.Flow Http subcontext
Apr 12, 2025
67313e9
Adjust Neos.Http.Factories to Neos.Flow Http subcontext adjustments
Apr 12, 2025
8eb4a31
Adjust Neos.Flow Error subcontext
Apr 12, 2025
7d642bd
Adjust Neos.Flow core
Apr 12, 2025
99dfdfe
Adjust Neos.Flow Configuration subcontext
Apr 12, 2025
3841ab6
Adjust Neos.Flow Composer subcontext
Apr 12, 2025
ce0b48b
Adjust Neos.Flow Cli subcontext
Apr 12, 2025
4e7cfe8
Adjust Neos.Flow Cache subcontext
Apr 12, 2025
f40b2b5
Adjust Neos.Flow Aop subcontext
Apr 12, 2025
cb01370
Adjust Neos.Flow Annotations subcontext
Apr 12, 2025
c9e5796
Adjust Neos.Flow application layer
Apr 12, 2025
2e0d642
Adjust Neos.Error.Messages
Apr 13, 2025
9333650
Adjust Neos.Eel
Apr 13, 2025
9da1ac8
Adjust Neos.Cache
Apr 13, 2025
ac2c3d0
add scanDirectories folders for special classes
Apr 13, 2025
e03ea34
TASK: Make $environmentConfiguration of AbstractBackend not optional
mhsdesign Apr 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 9 additions & 12 deletions Neos.Cache/Classes/Backend/AbstractBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ abstract class AbstractBackend implements BackendInterface

/**
* Reference to the cache frontend which uses this backend
* @var FrontendInterface
* @var ?FrontendInterface
*/
protected $cache;

/**
* @var string
* @var ?string
*/
protected $cacheIdentifier;

/**
* A prefix to seperate stored by appliaction context and cache
* @var string
* A prefix to separate stored by application context and cache
* @var ?string
*/
protected $identifierPrefix;

Expand All @@ -58,20 +58,17 @@ abstract class AbstractBackend implements BackendInterface
* Constructs this backend
*
* @param EnvironmentConfiguration $environmentConfiguration
* @param array $options Configuration options - depends on the actual backend
* @param array<mixed> $options Configuration options - depends on the actual backend
* @api
*/
public function __construct(?EnvironmentConfiguration $environmentConfiguration = null, array $options = [])
public function __construct(EnvironmentConfiguration $environmentConfiguration, array $options = [])
{
$this->environmentConfiguration = $environmentConfiguration;

if (is_array($options) || $options instanceof \Iterator) {
$this->setProperties($options);
}
$this->setProperties($options);
}

/**
* @param array $properties
* @param array<mixed> $properties
* @param boolean $throwExceptionIfPropertyNotSettable
* @return void
* @throws \InvalidArgumentException
Expand Down Expand Up @@ -117,7 +114,7 @@ public function setCache(FrontendInterface $cache): void
{
$this->cache = $cache;
$this->cacheIdentifier = $this->cache->getIdentifier();
$applicationIdentifier = $this->environmentConfiguration instanceof EnvironmentConfiguration ? $this->environmentConfiguration->getApplicationIdentifier() : '';
$applicationIdentifier = $this->environmentConfiguration->getApplicationIdentifier();
$this->identifierPrefix = md5($applicationIdentifier) . ':' . $this->cacheIdentifier . ':';
}

Expand Down
5 changes: 3 additions & 2 deletions Neos.Cache/Classes/Backend/ApcuBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function getPrefixedIdentifier(string $entryIdentifier): string
*
* @param string $entryIdentifier An identifier for this specific cache entry
* @param string $data The data to be stored
* @param array $tags Tags to associate with this cache entry
* @param array<string> $tags Tags to associate with this cache entry
* @param int|null $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
* @return void
* @throws Exception if no cache frontend has been set.
Expand Down Expand Up @@ -263,7 +263,7 @@ public function flushByTags(array $tags): int
* Associates the identifier with the given tags
*
* @param string $entryIdentifier
* @param array $tags
* @param array<string> $tags
* @return void
*/
protected function addIdentifierToTags(string $entryIdentifier, array $tags)
Expand Down Expand Up @@ -391,6 +391,7 @@ public function valid(): bool
*
* @return void
* @api
* @phpstan-assert \APCUIterator $this->cacheEntriesIterator
*/
#[\ReturnTypeWillChange]
public function rewind()
Expand Down
2 changes: 1 addition & 1 deletion Neos.Cache/Classes/Backend/BackendInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function getPrefixedIdentifier(string $entryIdentifier): string;
*
* @param string $entryIdentifier An identifier for this specific cache entry
* @param string $data The data to be stored
* @param array $tags Tags to associate with this cache entry. If the backend does not support tags, this option can be ignored.
* @param array<string> $tags Tags to associate with this cache entry. If the backend does not support tags, this option can be ignored.
* @param integer|null $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
* @return void
* @throws \Neos\Cache\Exception if no cache frontend has been set.
Expand Down
9 changes: 6 additions & 3 deletions Neos.Cache/Classes/Backend/FileBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class FileBackend extends SimpleFileBackend implements PhpCapableBackendInterfac
protected $cacheEntryFileExtension = '';

/**
* @var array<string>
* @var array<string, true> @phpstan-ignore property.phpDocType (this backend seems to work differently)
*/
protected $cacheEntryIdentifiers = [];

Expand Down Expand Up @@ -90,6 +90,9 @@ public function freeze(): void
$cachePathAndFileName = $this->cacheDirectory . 'FrozenCache.data';
if ($this->useIgBinary === true) {
$data = igbinary_serialize($this->cacheEntryIdentifiers);
if ($data === null) {
throw new \RuntimeException('Failed to serialize cache entry identifiers', 1744536663);
}
} else {
$data = serialize($this->cacheEntryIdentifiers);
}
Expand Down Expand Up @@ -140,8 +143,8 @@ public function setCache(FrontendInterface $cache): void
*
* @param string $entryIdentifier An identifier for this specific cache entry
* @param string $data The data to be stored
* @param array $tags Tags to associate with this cache entry
* @param integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
* @param array<string> $tags Tags to associate with this cache entry
* @param ?integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
* @return void
* @throws \RuntimeException
* @throws Exception if the directory does not exist or is not writable or exceeds the maximum allowed path length, or if no cache frontend has been set.
Expand Down
1 change: 1 addition & 0 deletions Neos.Cache/Classes/Backend/IterableBackendInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/**
* A contract for a cache backend which provides Iterator functionality.
*
* @extends \Iterator<int|string,mixed>
* @api
*/
interface IterableBackendInterface extends BackendInterface, \Iterator
Expand Down
15 changes: 15 additions & 0 deletions Neos.Cache/Classes/Backend/IterableMultiBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function current(): mixed
$this->prepareBackends();
foreach ($this->backends as $backend) {
try {
if (!method_exists($backend, 'current')) {
throw new \RuntimeException(get_class($backend) . ' does not implement rewind');
}
return $backend->current();
} catch (Throwable $throwable) {
$this->logger?->error('Failed retrieving current cache entry using backend ' . get_class($backend) . ' in ' . get_class($this) . ': ' . $this->throwableStorage?->logThrowable($throwable), LogEnvironment::fromMethodName(__METHOD__));
Expand All @@ -63,6 +66,9 @@ public function next(): void
$this->prepareBackends();
foreach ($this->backends as $backend) {
try {
if (!method_exists($backend, 'next')) {
throw new \RuntimeException(get_class($backend) . ' does not implement rewind');
}
$backend->next();
} catch (Throwable $throwable) {
$this->logger?->error('Failed retrieving next cache entry using backend ' . get_class($backend) . ' in ' . get_class($this) . ': ' . $this->throwableStorage?->logThrowable($throwable), LogEnvironment::fromMethodName(__METHOD__));
Expand All @@ -80,6 +86,9 @@ public function key(): string|int|bool|null|float
$this->prepareBackends();
foreach ($this->backends as $backend) {
try {
if (!method_exists($backend, 'key')) {
throw new \RuntimeException(get_class($backend) . ' does not implement rewind');
}
return $backend->key();
} catch (Throwable $throwable) {
$this->logger?->error('Failed retrieving cache entry key using backend ' . get_class($backend) . ' in ' . get_class($this) . ': ' . $this->throwableStorage?->logThrowable($throwable), LogEnvironment::fromMethodName(__METHOD__));
Expand All @@ -98,6 +107,9 @@ public function valid(): bool
$this->prepareBackends();
foreach ($this->backends as $backend) {
try {
if (!method_exists($backend, 'valid')) {
throw new \RuntimeException(get_class($backend) . ' does not implement rewind');
}
return $backend->valid();
} catch (Throwable $throwable) {
$this->logger?->error('Failed checking if current cache entry is valid using backend ' . get_class($backend) . ' in ' . get_class($this) . ': ' . $this->throwableStorage?->logThrowable($throwable), LogEnvironment::fromMethodName(__METHOD__));
Expand All @@ -116,6 +128,9 @@ public function rewind(): void
$this->prepareBackends();
foreach ($this->backends as $backend) {
try {
if (!method_exists($backend, 'rewind')) {
throw new \RuntimeException(get_class($backend) . ' does not implement rewind');
}
$backend->rewind();
} catch (Throwable $throwable) {
$this->logger?->error('Failed rewinding cache entries using backend ' . get_class($backend) . ' in ' . get_class($this) . ': ' . $this->throwableStorage?->logThrowable($throwable), LogEnvironment::fromMethodName(__METHOD__));
Expand Down
16 changes: 8 additions & 8 deletions Neos.Cache/Classes/Backend/MemcachedBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MemcachedBackend extends IndependentAbstractBackend implements TaggableBac
/**
* Array of Memcache server configurations
*
* @var array
* @var array<string>
*/
protected $servers = [];

Expand Down Expand Up @@ -102,7 +102,7 @@ public function __construct(EnvironmentConfiguration $environmentConfiguration,
* Setter for servers to be used. Expects an array, the values are expected
* to be formatted like "<host>[:<port>]" or "unix://<path>"
*
* @param array $servers An array of servers to add.
* @param array<string> $servers An array of servers to add.
* @return void
* @throws Exception
* @api
Expand All @@ -121,12 +121,12 @@ protected function setServers(array $servers)
$host = $server;
$port = 0;

if (strpos($server, 'tcp://') === 0) {
if (str_starts_with($server, 'tcp://')) {
$port = $defaultPort;
$server = substr($server, 6);
}

if (strpos($server, ':') !== false) {
if (str_contains($server, ':')) {
[$host, $portValue] = explode(':', $server, 2);
$port = (int)$portValue;
}
Expand Down Expand Up @@ -192,8 +192,8 @@ public function getPrefixedIdentifier(string $entryIdentifier): string
*
* @param string $entryIdentifier An identifier for this specific cache entry
* @param string $data The data to be stored
* @param array $tags Tags to associate with this cache entry
* @param integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
* @param array<string> $tags Tags to associate with this cache entry
* @param ?integer $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
* @return void
* @throws Exception if no cache frontend has been set.
* @throws \InvalidArgumentException if the identifier is not valid or the final memcached key is longer than 250 characters
Expand Down Expand Up @@ -325,7 +325,7 @@ public function findIdentifiersByTag(string $tag): array
* index to search for tags.
*
* @param string $identifier Identifier to find tags by
* @return array Array with tags
* @return array<string> Array with tags
*/
protected function findTagsByIdentifier(string $identifier): array
{
Expand Down Expand Up @@ -383,7 +383,7 @@ public function flushByTags(array $tags): int
* Associates the identifier with the given tags
*
* @param string $entryIdentifier
* @param array $tags
* @param array<string> $tags
* @return void
*/
protected function addIdentifierToTags(string $entryIdentifier, array $tags)
Expand Down
16 changes: 13 additions & 3 deletions Neos.Cache/Classes/Backend/MultiBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ class MultiBackend extends AbstractBackend
{
use BackendInstantiationTrait;

/**
* @var array<mixed>
*/
protected array $backendConfigurations = [];
/**
* @var array<int,BackendInterface>
*/
protected array $backends = [];
protected bool $setInAllBackends = true;
protected bool $debug = false;
Expand All @@ -41,17 +47,15 @@ class MultiBackend extends AbstractBackend
protected ?LoggerInterface $logger = null;
protected ?ThrowableStorageInterface $throwableStorage = null;

public function __construct(?EnvironmentConfiguration $environmentConfiguration = null, array $options = [])
public function __construct(EnvironmentConfiguration $environmentConfiguration, array $options = [])
{
parent::__construct($environmentConfiguration, $options);

if ($this->logErrors && class_exists(Bootstrap::class) && Bootstrap::$staticObjectManager instanceof ObjectManagerInterface) {
try {
$logger = Bootstrap::$staticObjectManager->get(LoggerInterface::class);
assert($logger instanceof LoggerInterface);
$this->logger = $logger;
$throwableStorage = Bootstrap::$staticObjectManager->get(ThrowableStorageInterface::class);
assert($throwableStorage instanceof ThrowableStorageInterface);
$this->throwableStorage = $throwableStorage;
} catch (UnknownObjectException) {
// Logging might not be available during compile time
Expand All @@ -78,11 +82,15 @@ protected function prepareBackends(): void
}

/**
* @param array<mixed> $backendOptions
* @throws Throwable
*/
protected function buildSubBackend(string $backendClassName, array $backendOptions): ?BackendInterface
{
try {
if ($this->cache === null) {
throw new \RuntimeException('Cache frontend is not yet initialized', 1744535490);
}
$backend = $this->instantiateBackend($backendClassName, $backendOptions, $this->environmentConfiguration);
$backend->setCache($this->cache);
} catch (Throwable $throwable) {
Expand All @@ -95,6 +103,7 @@ protected function buildSubBackend(string $backendClassName, array $backendOptio

/**
* @throws Throwable
* @param array<string> $tags
*/
public function set(string $entryIdentifier, string $data, array $tags = [], ?int $lifetime = null): void
{
Expand Down Expand Up @@ -204,6 +213,7 @@ public function collectGarbage(): void

/**
* This setter is used by AbstractBackend::setProperties()
* @param array<mixed> $backendConfigurations
*/
protected function setBackendConfigurations(array $backendConfigurations): void
{
Expand Down
4 changes: 2 additions & 2 deletions Neos.Cache/Classes/Backend/NullBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ protected function setProperty(string $propertyName, $propertyValue) : bool
*
* @param string $entryIdentifier ignored
* @param string $data ignored
* @param array $tags ignored
* @param integer $lifetime ignored
* @param array<string> $tags ignored
* @param ?integer $lifetime ignored
* @return void
* @api
*/
Expand Down
9 changes: 5 additions & 4 deletions Neos.Cache/Classes/Backend/PdoBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PdoBackend extends IndependentAbstractBackend implements TaggableBackendIn
protected $password;

/**
* @var array
* @var array<mixed>
*/
protected $driverOptions = [];

Expand Down Expand Up @@ -83,7 +83,7 @@ class PdoBackend extends IndependentAbstractBackend implements TaggableBackendIn
protected $batchSize = 999;

/**
* @var \ArrayIterator|null
* @var \ArrayIterator<string,mixed>|null
*/
protected $cacheEntriesIterator;

Expand Down Expand Up @@ -126,7 +126,7 @@ protected function setPassword(string $password): void
/**
* Sets the driverOptions to use
*
* @param array $driverOptions The options to use for connecting to the DB
* @param array<mixed> $driverOptions The options to use for connecting to the DB
* @return void
* @api
*/
Expand Down Expand Up @@ -174,7 +174,7 @@ protected function setBatchSize(int $batchSize): void
*
* @param string $entryIdentifier An identifier for this specific cache entry
* @param string $data The data to be stored
* @param array $tags Tags to associate with this cache entry
* @param array<string> $tags Tags to associate with this cache entry
* @param int|null $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
* @return void
* @throws Exception if no cache frontend has been set.
Expand Down Expand Up @@ -613,6 +613,7 @@ public function valid(): bool
*
* @return void
* @api
* @phpstan-assert \ArrayIterator<string,mixed> $this->cacheEntriesIterator
*/
public function rewind(): void
{
Expand Down
Loading
Loading