The SmsGatewayForm doesn't work anymore on Drupal 8.4.0 due to some changes to DefaultSingleLazyPluginCollection
in #2851635: DefaultSingleLazyPluginCollection retains stale instance IDs.
The failure is because the new implementation expects non-null plugin IDs to be provided to the DefaultSingleLazyPluginCollection
's constructor. This is not what is currently done by the SmsGatewayForm
#2857911-12: Use setConfiguration() to merge default configuration values
SmsGateway::getPluginCollections()
gets called without any initial values byEntityForm::copyFormValuesToEntity()
without the plugin type first being initialized. This is because of how ourSmsGatewayForm
is implemented: the form is first created without specifying the plugin type because we want to use the same form to choose the plugin type.
Solution - override the DefaultSingleLazyPluginCollection
constructor and check for non-null plugin ID first before trying to instantiate it.
Comments
Comment #2
almaudoh CreditAttribution: almaudoh commentedFunny that the patch didn't trigger testbot. Re-uploading...
Comment #3
almaudoh CreditAttribution: almaudoh commentedComment #5
almaudoh CreditAttribution: almaudoh commentedPlugin auto-discovery and configuration is still murky waters for me. I've used the simplest approach possible. Hope it doesn't break any tests.
Also fixed a couple of docs nits along the way.
Comment #7
dpiI'm still a little while off setting up a 8.4.x site, so I don't think Ill give this attention for a while.
Could this be the issue? Configurable plugins should merge default configuration values within setConfiguration()
Comment #8
almaudoh CreditAttribution: almaudoh commentedYep! That was the issue. Funny I'd been following that issue and yet it never occurred to me that it was the cause.
So, here's the final fix.
Comment #9
almaudoh CreditAttribution: almaudoh commentedComment #10
dpi???
Comment #11
dpiComment #12
almaudoh CreditAttribution: almaudoh commentedThat's what makes this patch work actually.
This is the problem: in
Entity\SmsGateway
SmsGateway::getPluginCollections()
gets called without any initial values byEntityForm::copyFormValuesToEntity()
without the plugin type first being initialized. This is because of how ourSmsGatewayForm
is implemented: the form is first created without specifying the plugin type because we want to use the same form to choose the plugin type.Comment #13
dpiThis is weird. There are different problems if we are required to hard code a fallback plugin id.
Comment #14
almaudoh CreditAttribution: almaudoh commentedI just encountered this issue again (I'd forgotten about it). Drupal 8.4.0-beta1 is out, stable is due in October. We need to fix this.
What kind of problems are you seeing?
The only other options I can see are to override the
DefaultSinglePluginCollection
constructor in ourSmsGatewayPluginCollection
and revert to the original implementation (don't call$this->addInstanceId()
), or we change the way we're implementing the plugin form.I'll post alternative patches later on today.
Comment #15
almaudoh CreditAttribution: almaudoh commentedSo, a much neater approach following #14. No need to hardcode the fallback gateway, but we have to override the constructor and only call
$this->addInstanceId()
if there is a plugin ID specified.Comment #16
almaudoh CreditAttribution: almaudoh commented:)
Comment #17
almaudoh CreditAttribution: almaudoh commentedTests pass on D8.4. I will commit this by the end of the day if there is no further objection to the approach.
Comment #18
almaudoh CreditAttribution: almaudoh commentedComment #19
almaudoh CreditAttribution: almaudoh commentedComment #20
dpiAwesome
See also #2903585: Create Drupal 8.4 compatible release
Comment #21
almaudoh CreditAttribution: almaudoh commentedOk. Great. Committed / pushed to 8.x-1.x