-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add service to use config parameters in custom storage like DB #10357
Conversation
Codecov Report
@@ Coverage Diff @@
## 4.x #10357 +/- ##
============================================
+ Coverage 42.14% 42.16% +0.01%
- Complexity 34533 34545 +12
============================================
Files 2062 2065 +3
Lines 111560 111584 +24
============================================
+ Hits 47021 47045 +24
Misses 64539 64539
|
@kuzmany just updated the base for you to 4.x as it's a feature PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kuzmany I made some comments just by reading the code. I have not tested it. It needs code coverage for the new services and that existing services still work as expected.
|
||
parent::__construct( | ||
new \Symfony\Component\Cache\Adapter\PdoAdapter($connection, (string) $namespace, $lifetime, $options), | ||
new \Symfony\Component\Cache\Adapter\PdoAdapter($connection, (string) $namespace, $lifetime, $options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to duplicate this?
{ | ||
if (is_null($this->psr16)) { | ||
$this->psr16 = new Psr6Cache($this->getCacheAdapter()); | ||
$this->psr16 = new Psr6Cache($this->getCacheAdapter($cacheAdapter)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will cause issues when the cache provider is used for caching (i.e. Redis) and the database (for config) because first to call the method wins resulting subsequent to use something other than the cache adaptor configured.
Consider using a complete new service for this instead of sharing the same as the cache provider. DatabaseParametersStorage could potentially use the same class but should be defined as a new/separate service.
'mautic.parameters.storage.database' => [ | ||
'class' => \Mautic\CoreBundle\ParametersStorage\Database\DatabaseParametersStorage::class, | ||
'arguments' => [ | ||
'mautic.cache.provider', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment above about using a new service instead of sharing mautic.cache.provider
|
||
public function write(array $parameters): void | ||
{ | ||
$this->simpleCache->set(ParametersStorage::PARAMETERS_STORAGE, $parameters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm torn on this. I see the benefit of quicker coding by using the cache provider to do this but I also think it's a bit risky because important configuration options will be stored in the same location as cached items. It'll need to be called out that using the DB to store parameters means you cannot reset or truncate the database cache blindly. If using a different service than the shared mautic.cache.provider
, maybe you could use a new table just for config parameters as well to help protect from that scenario?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alanhartless thank you for your comments. Do you mean use cache service with store to another table like cache_items or do you mean create new table as part of Mautic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new table that stores just config values that doesn't get tangled up in other cached items because the mautic.cache.provider
service is shared for both.
// if db_driver and mailer_from_name are present then it is assumed all the steps of the installation have been | ||
// performed; manually deleting these values or deleting the config file will be required to re-enter | ||
// installation. | ||
if (empty($params['db_driver']) || empty($params['mailer_from_name'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this check moved somewhere else? If not, then was the installer tested with the default file based config? It looks like this method is used in a few places so I'm not sure of the full impact of removing this nor if there is really any value in having it now.
…cache provider in code mautic#10513" This reverts commit 09d954b
5123b1e
to
6f056b2
Compare
Close, we need release M5 version of the solution |
Description:
This PR allow developer create own storage for parameters - by default store in local.php. Some enviroment infrastructure do not allow change it static files due server replication. You can use database or redis or enything else.
Example of service for parameters storage:
Then in in
parameters_local.php
you set\Mautic\CoreBundle\ParametersStorage\ParametersStorage::PARAMETERS_STORAGE => 'mautic.parameters.storage.database',
This PR also include Add support for database cache provider + allow use multiple cache provider in code
Cache component (https://developer.mautic.org/#cache-bundle) in Mautic support at the moment filesystem, memcached a redis mechanism. This PR add database cache adapter (https://symfony.com/doc/current/components/cache/adapters/pdo_doctrine_dbal_adapter.html)
Also this allow use multiple cache provider in your code.
and
Just setup in
parameters_local.php
'cache_adapter' => 'mautic.cache.adapter.db',
You can also change there timeout to never expired data
Steps to test this PR: