Transport list should reflect non-overridden config

Created on 2 October 2023, 9 months ago
Updated 26 October 2023, 8 months ago

Problem/Motivation

We use settings.php to override the default transport.
Admin pages that allow editing config should reflect the database config and not overrides.
But /admin/config/system/mailer/transport lists the overridden default.

Steps to reproduce

Create 2 transports and set one as default.
Add something like this to settings.php to set the other one as default:

$config['symfony_mailer.settings']['default_transport'] = 'mailhog';

Proposed resolution

MailerTransportListBuilder::buildRow() should use the non-overridden config to check if a transport is the default one.

🐛 Bug report
Status

Fixed

Version

1.3

Component

Code

Created by

🇫🇷France prudloff Lille

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @prudloff
  • 🇫🇷France prudloff Lille

    Note that the label is already loaded without overrides on this page for example.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    7 pass
  • @prudloff opened merge request.
  • Status changed to Needs review 9 months ago
  • 🇬🇧United Kingdom AdamPS

    Please let me check I understand. When mails get sent out from your site, by default they will use the override: 'mailhog'. If you look in GUI on the transport listing page, it reports that 'mailhog' is the default. However you think this is wrong, and that it should report the other transport?? Can you show any example in Core to confirm that this is correct?

  • 🇫🇷France prudloff Lille

    The admin page allows editing config so it should always display the config that is being edited.
    Here is an example of why this can be confusing: if I click "set as default" on another transport, nothing happens visually (mailhog is still displayed as default because of the override) but my config has changed. The page should reflect the config change.

    It is explained here .

    The core uses it for example in GDToolkit::buildConfigurationForm() or in ThemeExperimentalConfirmForm.

    🐛 Prevent saving config entities when configuration overrides are applied Needs work also talks about preventing saving the configuration when it contains overrides.
    🐛 There is no indication on configuration forms if there are overridden values Needs work also discusses the fact that core philosophy is that config forms don't display overrides (and suggests displaying the overrides in a warning message, not in the form itself).

  • Status changed to Needs work 9 months ago
  • 🇬🇧United Kingdom AdamPS

    Thanks for explaining, that makes sense. It would be clearer for me if we copy how it's done in the docs you link to, so like this:

    // Get the default transport without overrides.
    return \Drupal::config('symfony_mailer.settings')->getOriginal('default_transport') == $this->id();
    
  • 🇫🇷France prudloff Lille

    The config returned is never modified so I think you are right we can use getOriginal() instead of getEditable().
    I updated the MR.

  • Status changed to Needs review 8 months ago
  • Status changed to Fixed 8 months ago
  • 🇬🇧United Kingdom AdamPS

    Thanks

  • 🇳🇱Netherlands mishavantol Haarlem

    Now it is unclear the other way around. I was wondering why my local dev setting (mailhog) wasn't showing up in the transport overview. After all, the intention is to adjust the default_transport in a specific environment. Even more confusing is that the overwritten setting is used when sending the test email. So the overview says sendmail is the default, but we use mailhog as the default when sending.

  • 🇳🇱Netherlands mishavantol Haarlem

    Now it is unclear the other way around. I was wondering why my local dev setting (mailhog) wasn't showing up in the transport overview. After all, the intention is to change the default_transport in a specific environment. Even more confusing is that the overwritten setting is used when sending the test email. So the overview says sendmail is the default, but we use mailhog as the default when sending.

  • 🇫🇷France prudloff Lille

    Well, that is the behavior of most of the Drupal back-office when using overridden config.
    This is why the config_override_warn module exists (until 🐛 There is no indication on configuration forms if there are overridden values Needs work is fixed).

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024