Closed (fixed)
Project:
SMTP Authentication Support
Version:
8.x-1.0-rc4
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
29 Jan 2021 at 03:11 UTC
Updated:
15 Dec 2025 at 21:44 UTC
Jump to comment: Most recent
Comments
Comment #2
patrickharris commentedComment #3
tr commentedI don't understand the problem. How else would you do it? This is a configuration form used to set and change the SMTP module settings - it HAS to get the editable smtp.settings configuration in order to be able to change the settings. This is the way all core modules do it. These days it's more common to implement
getEditableConfigNames(), but that's just a convenience function which does the EXACT SAME THING asgetEditable()*. This convenience function didn't exist back in the early days of D8 when the SMTP module was ported which I assume is why the SMTP module doesn't currently use it.*Specifically, for classes that extend
ConfigFormBase,$this->configFactory->getEditable('smtp.settings')will return the exact same thing as the combination ofprotected function getEditableConfigNames() { return ['smtp.settings']; }and$this->config('smtp.settings').Comment #4
tr commentedIMO, in this matter the SMTP module operates exactly as documented and expected for core and contributed modules. See https://www.drupal.org/docs/drupal-apis/configuration-api/configuration-... for a description of configuration overrides and how they work.
Because overrides are a core feature which apply to all configuration entities. any extension of this core mechanism to, for example, display the overridden values should be handled by core. There are links in the above documentation that point to core issues/discussions about doing this on a general basis and not just for one specific module. For example #2408549: Display status message on configuration forms when there are overridden values.
Perhaps I've misunderstood or missed some use case, but if not I am in favor of marking this as "Closed, works as designed", or at the very lease, "Closed, duplicate" (duplicate of #2408549: Display status message on configuration forms when there are overridden values).
Comment #5
patrickharris commentedThanks TR - I think what confused me was that an earlier D8 version of the smtp module actually used
$this->configFactory->get('smtp.settings');(the 'live' variables actually used).Yes, I think you are right, that the module is functioning correctly with
$this->configFactory->getEditable('smtp.settings')and that viewing the overridden variables is a generic problem that needs to be solved in Drupal core.Comment #6
lowfidelityI realized this behavior today and ran into troubles, when trying to send a test mail from /admin/config/system/smtp .
In settings.php I'm using this line to override the smtp server's host:
$config['smtp.settings']['smtp_host'] = 'some.host.xyz';With older versions (ie. Core 8.7.x and SMTP Auth. Support 8.x-1.0-beta4) when I open /admin/config/system/smtp I can see the disabled field and it contains the overrideen address of the smtp host.
With a newer setup (ie. Core 8.9.x and smtp 8.x-1.0-rc4) when I open /admin/config/system/smtp I can still see the disabled field, but it contains the value originally entered in the config form not the one overridden in settings.php.
In my case I never entered a smtp hostname in the config form, only in settings.php. So the field is disabled and empty. When I then try to send a test mail from the config form at /admin/config/system/smtp I receive the error:
You must enter an SMTP server address. Obviously because the field is empty.I didn't dare trying it out, but I wonder wether the SEND TEST E-MAIL function uses the overridden value from settings.php, or the one from the config form. Other mails (ie. password reset) are correctly using the overridden hostname from settings.php.
Comment #7
patrickharris commentedThe SEND TEST E-MAIL uses the overridden value, which is correct. However as pointed out, the form won't submit until a legitimate 'un-overriden' configuration is entered, which of course is unnecessary and extremely confusing.
Perhaps the SEND TEST E-MAIL could be moved to a separate tab which displays the 'real' overriden values that will be used for the test? This would kill a few birds with one stone!
Comment #8
ivnate commentedI have exact same issue.
1. configure smtp module via settings.php
2. go to /admin/config/system/smtp
3. send test email
4. Receive "You must enter an SMTP server address" validation error.
Two potential solutions:
1. As you mention, move test form to a different tab/page.
2. Change form validation so it recognizes fields that are set via config and do not validate them.
Comment #10
bluegeek9 commentedComment #13
bluegeek9 commentedSince the form element is disabled if the value is overridden, and since overridden values are not saved, @see SMTPConfigForm::submitForm
I update buildForm to show the overridden values.
I also added more tests.
Comment #14
bluegeek9 commentedComment #15
bluegeek9 commentedI want to make improvements to how this is handled.
Comment #16
bluegeek9 commentedI removed the custom methods and used built-in methods.
Comment #19
bluegeek9 commentedComment #21
japerryThis commit created some BC issues and needs to be partially reverted. Setting to NW.
Comment #23
bluegeek9 commentedWhat are the bc?
Comment #24
japerrySince the form is not 'final' the constructor signature is different. While its a minor change, we cannot guarantee that no one has extended this form, without making a major change.
Also, unit tests are.. ehh not the greatest. Converted it into a Kernel test. It'd be even better if it was doing request based kernel tests, but this at least confirms the values entered should be returning correctly when submitted.
Comment #25
japerryComment #28
bluegeek9 commentedI made a MR that uses a constructor, but maintains backwards compatibility.
Comment #30
bluegeek9 commented