Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes

Problem/Motivation

In #2199795: Make the Settings class prevent serialization of actual settings we identified that serializing the settings is problematic, but we did not actually replaced all instances.

Proposed resolution

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
24.01 KB

Let's fix stuff.

Status: Needs review » Needs work

The last submitted patch, 1: 2443351-1.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
25.52 KB
3.73 KB

FIxed the failures.

Status: Needs review » Needs work

The last submitted patch, 3: 2443351-3.patch, failed testing.

dawehner’s picture

Does someone is able to spot the problem of the YML file?

larowlan’s picture

Status: Needs work » Needs review
FileSize
777 bytes
25.92 KB

this makes a difference locally

Status: Needs review » Needs work

The last submitted patch, 6: settings-params-2443351.2.patch, failed testing.

larowlan’s picture

Status: Needs work » Needs review
FileSize
1.55 KB
25.54 KB

and so does this

Status: Needs review » Needs work

The last submitted patch, 8: settings-params-2443351.3.patch, failed testing.

dawehner’s picture

@larowlan
This is what I don't understand, those lines aren't even touched, see #6

dawehner’s picture

Status: Needs work » Needs review
FileSize
26.34 KB
820 bytes

Let's fix it.

Status: Needs review » Needs work

The last submitted patch, 11: 2443351-11.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
31.74 KB
5.54 KB

Nearly fixed all of them.

Status: Needs review » Needs work

The last submitted patch, 13: 2443351-13.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
31.82 KB
779 bytes

There we go.

Berdir’s picture

  1. +++ b/core/core.services.yml
    @@ -5,6 +5,11 @@ parameters:
    +  session_write_interval: 180
    

    I recently saw that we have a SessionConfiguration service, that makes the session configuration stuff easier to access, just wondering if it would make sense to put that in there as well?

  2. +++ b/core/core.services.yml
    @@ -277,7 +282,7 @@ services:
    -    arguments: ['@settings']
    

    Do you plan to actually remove it from the container?

    We tried to be as nice as possible with the error when the container is serialized (php notice/warning), but at the moment that is pointless because it always results in an exception due to settings being serialized as well.

  3. +++ b/core/lib/Drupal/Core/File/FileSystem.php
    @@ -48,19 +40,31 @@ class FileSystem implements FileSystemInterface {
    +    $file_chmod_configuration += [
    +      'directory' => static::CHMOD_DIRECTORY,
    +      'file' => static::CHMOD_FILE,
    +    ];
    +    $this->fileChmodConfiguration = $file_chmod_configuration;
    

    Are there more keys than those two? Should we maybe make them separate properties instead of accessing it as an array?

  4. +++ b/core/lib/Drupal/Core/Session/MetadataBag.php
    @@ -23,12 +22,11 @@ class MetadataBag extends SymfonyMetadataBag {
    +  public function __construct($session_write_interval = 180) {
    

    does the default value like this actually make sense? if it's always called through the container, not so much?

    Maybe it should be an if (empty) set default check?

  5. +++ b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
    @@ -23,23 +22,28 @@ class ReverseProxyMiddleware implements HttpKernelInterface {
    +    $reverse_proxy_configuration += [
    +      'header' => 'X_FORWARDED_FOR',
    +      'addresses' => [],
    +    ];
    +    $this->reverseProxyConfiguration = $reverse_proxy_configuration;
    

    same here, for configurations where we have a fixed set of keys, I think separate properties would be easier to write/document. We could still pass it in as an array...

  6. +++ b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
    @@ -47,10 +51,10 @@ public function __construct(HttpKernelInterface $http_kernel, Settings $settings
    -      $proxies = $this->settings->get('reverse_proxy_addresses', array());
    +      $proxies = $this->reverseProxyConfiguration['addresses'];
           if (count($proxies) > 0) {
             $request::setTrustedProxies($proxies);
           }
    

    For example here, you could just replace $proxies with $this->proxies or proxyAddresses or something.

  7. +++ b/core/modules/language/src/LanguageNegotiator.php
    @@ -190,7 +180,7 @@ protected function negotiateLanguage($type, $method_id) {
           // Check for a cache mode force from settings.php.
    -      if ($this->settings->get('page_cache_without_database')) {
    +      if (Settings::get('page_cache_without_database')) {
             $cache_enabled = TRUE;
    

    this will go away in the page_cache.module issue, but I'm not actually sure we thought of removing the constructor argument there...

  8. +++ b/core/modules/system/src/Tests/Session/SessionTest.php
    @@ -228,13 +230,13 @@ function testSessionWrite() {
    +    $filename = $this->siteDirectory . '/services.yml';
    +    $data = Yaml::decode(file_get_contents($filename));
    +    $data['parameters']['session_write_interval'] = 0;
    +    file_put_contents($filename, Yaml::encode($data));
    +    YamlFileLoader::reset();
    +    $this->rebuildContainer();
    

    Don't we have a helper for this? or only for settings.php? should we have a helper?

    Just checked, didn't find anything, but might be worth it, especially considering that we might end up doing this multiple times, and the helper should be intelligent enough to remember existing settings or so?

    For example, this might overwrite the existing services.yml written in WebTestBase::setUp().

Berdir’s picture

On 8., found it, there's setContainerParameter in WebTestBase.

Also forget the stuff about remember existing values, didn't notice that you read the file first.

dawehner’s picture

I recently saw that we have a SessionConfiguration service, that makes the session configuration stuff easier to access, just wondering if it would make sense to put that in there as well?

OH right, there is that. I'll assume for now we skipped that setting not on purpose.

Do you plan to actually remove it from the container?

Sure, this is the entire point of it.

Are there more keys than those two? Should we maybe make them separate properties instead of accessing it as an array?

No its, just those two. It totally makes sense to use two variables.

Just checked, didn't find anything, but might be worth it, especially considering that we might end up doing this multiple times, and the helper should be intelligent enough to remember existing settings or so?

Good catch. I guess we want to have the same framework as the rewriteSettings one.

Wim Leers’s picture

Nice! :) Also makes the DX more consistent, by moving as much as possible out of settings.php, into the site-specific services.yml.

  1. +++ b/sites/default/default.services.yml
    @@ -88,3 +88,71 @@ parameters:
    +  # factory.queue: {}
    ...
    +  # session_write_interval: 180
    

    Let's not comment these; they match the default values.

    That also makes this a bit easier to parse.

    (Right now it's very confusing to read: it's difficult to see what's a header versus explanation versus value.)

  2. +++ b/sites/default/default.services.yml
    @@ -88,3 +88,71 @@ parameters:
    +  # reverse_proxy:
    ...
    +  # file_chmod:
    

    And let's add

    reverse_proxy/file_chmod:
      {}
    

    for these, for similar reasons. This is consistent with how factory.keyvalue etc. are handled.

dawehner’s picture

FileSize
33.53 KB
2.93 KB

Alright, there we go.

Fixed also the injection of the settings into the CacheFactory

Wim Leers’s picture

+++ b/core/lib/Drupal/Core/Cache/CacheFactory.php
@@ -20,9 +20,9 @@ class CacheFactory implements CacheFactoryInterface,  ContainerAwareInterface {
   protected $settings;

@@ -49,7 +49,7 @@ class CacheFactory implements CacheFactoryInterface,  ContainerAwareInterface {
+    $this->cacheSettings = $settings->get('cache');

Now no longer matching.

dawehner’s picture

FileSize
571.11 KB
945 bytes

.

rteijeiro’s picture

FileSize
34.35 KB
2.28 KB

Re-rolled and fixed.

dawehner’s picture

Re-rolled and fixed.

Oh, Opened #2461435: Add integration test coverage for ReverseProxyMiddleware based upon that.

dawehner queued 23: 2443351-23.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 23: 2443351-23.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
33.95 KB

Reroll

Status: Needs review » Needs work

The last submitted patch, 27: 2443351-27.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
33.95 KB
761 bytes

Meh.

alexpott’s picture

How is this a bug? I agree that in an ideal world these things should be container params but drupal currently works fine with them not being.

dawehner’s picture

Category: Bug report » Task

Well, its a bug in the sense that with Settings() being no longer serializable, potentially custom code which serializes something would break.
I'm fine with moving it to a task ...

dawehner’s picture

Version: 8.0.x-dev » 9.x-dev

Seems to be 9.x material. Open a follow up to fix the problem I had with it: #2473347: Don't store the language manager as static property on \Drupal\views\Views

vijaycs85’s picture

@alexpott, I believe we are going to get surprise regressions like #2502195: \Drupal\Core\StringTranslation\Translator\CustomStrings should be serializable, but contain \Drupal\Core\Site\Settings which is not until we have settings as a service in core. IMHO, this issue should be a 8.0.x bug.

dawehner’s picture

As intermediate step I think removing the settings service and always use the singleton directly would be a good way forward to solve the potential problems.

catch’s picture

Version: 9.x-dev » 8.1.x-dev
Status: Needs review » Postponed

I think we should look at:

- add the container parameters

- check settings first

- eventually E_DEPRECATED when the setting is found.

That lets us transition gradually to container parameters while maintaining bc.

Also using the settings singleton directly instead of the service looks fine for minor releases, even if we leave the service itself in and deprecated.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

catch’s picture

Status: Postponed » Active

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

alexpott’s picture

I think we can do something like #3061535: Add settings from settings.php to the container as parameters to help us move to not using settings.php.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

andypost’s picture

Status: Active » Needs work

proper status

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.