Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop when fetching some cache-related services via container in projects without registered config service #286

Merged
merged 11 commits into from
Jan 19, 2024

Conversation

InvisibleSmiley
Copy link

@InvisibleSmiley InvisibleSmiley commented Jan 17, 2024

Q A
Documentation no
Bugfix yes
BC Break no
New Feature no
RFC no
QA no

Description

Add regression test for issue #284

Signed-off-by: Jens Hatlak <jens.hatlak@check24.de>
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
…te on projects without project configuration

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
This fixes an infinite loop in combination with `laminas-servicemanager` as outlined in laminas#284

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
@boesing boesing added the Bug Something isn't working label Jan 17, 2024
@boesing boesing added this to the 3.12.1 milestone Jan 17, 2024
@boesing boesing changed the title Add regression test for issue 284 Infinite loop when fetching some cache-related services via container in projects without registered config service Jan 17, 2024
@boesing boesing linked an issue Jan 17, 2024 that may be closed by this pull request
Copy link
Member

@boesing boesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :trollface:

…` method is not calling container

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
Copy link
Member

@gsteel gsteel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spotted a typo in the docs, and also the constant name PRESERVED_ should be RESERVED_ right?

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
@@ -14,7 +14,8 @@
*/
class StorageCacheAbstractServiceFactory implements AbstractFactoryInterface
{
public const CACHES_CONFIGURATION_KEY = 'caches';
public const CACHES_CONFIGURATION_KEY = 'caches';
private const RESERVED_CONFIG_SERVICE_NAME = 'config';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why introduce constant? Lines 76 and 81 are not using it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because its way more readable than just having a random string somewhere.
The get does not need to check for the requested name as it shouldn't get passed due to the canCreate method returning false (implicit check).

I did a quick lookup with phpdbg and from what I can see, having this constant does not even produce more opcodes than using string here.

So IMHO, due to readability and same opcode amount, it should be fine having this around.

Comment on lines -40 to +44
The factory `Laminas\Cache\Service\StorageCacheAbstractServiceFactory` uses the configuration, searches for the configuration key `caches` and creates the storage adapters using the discovered configuration.
The factory `Laminas\Cache\Service\StorageCacheAbstractServiceFactory` uses the configuration, searches for the configuration key `caches` and creates the storage adapters using the discovered configuration.

WARNING: **Cache Named `config` Is Not Possible**
A cache named `config` is not possible due to internal service conflicts with MVC configuration.
The service named `config` is reserved for project configuration and thus cannot be used with the `caches` configuration.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cache name must be unique identifier in container. Not just config but any conflicting name is not possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yah but thats usually up to the user while it is not for config as we now do have explicit check within the abstract static factory.
So I think this might be good enough for now. We still should tackle this specific issue within laminas-servicemanager.

@boesing boesing merged commit bf8bc7f into laminas:3.12.x Jan 19, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ServiceManager::get results in endless loop since 3.11.0
5 participants