Problem/Motivation

UpdateSettingsForm inherited from ConfigFormBase which needs ConfigFactoryInterface as argument but it is not set, the form works because config has fallback to global \Drupal

Proposed resolution

Call parent static create($container) in own overridden method to comform interface and inheritance

Remaining tasks

decide on approach (comment #9) and commit

User interface changes

no

API changes

construction of form may change but constructors are not a part of BC

Data model changes

no

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost created an issue. See original summary.

andypost’s picture

Status: Active » Needs review
FileSize
609 bytes

For 8.x it could use this patch to keep BC

andypost’s picture

Or could be like that patch

andypost’s picture

FileSize
385 bytes
1.02 KB

Missed return

andypost’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Looks the form missing tests (only in core/modules/update/tests/src/Functional/UpdateCoreTest.php it used to get)

kishor_kolekar’s picture

Assigned: Unassigned » kishor_kolekar
Status: Needs work » Needs review
FileSize
1.24 KB
1.37 KB
kishor_kolekar’s picture

Assigned: kishor_kolekar » Unassigned
pratik_kamble’s picture

@kishor_kolekar, Patch by @andypost is the correct way to extend classes. FYR: https://www.previousnext.com.au/blog/safely-extending-drupal-8-plugin-cl...

alexpott’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests
+++ b/core/modules/update/src/UpdateSettingsForm.php
@@ -23,23 +23,15 @@ class UpdateSettingsForm extends ConfigFormBase implements ContainerInjectionInt
   public static function create(ContainerInterface $container) {
-    return new static(
-      $container->get('email.validator')
+    $instance = new static(
+      $container->get('config.factory')
     );
+    $instance->emailValidator = $container->get('email.validator');
+    return $instance;
   }

If we're going to do this to insulate ourselves from upstream constructor changes then we need to do $instance = parent::create(); - otherwise we might as well do the patch in #6

@andypost I think that as long as we hit the route in a test then we're okay because that means the form is being constructed and so we have test coverage of the changes here.

pratik_kamble’s picture

Assigned: Unassigned » pratik_kamble
pratik_kamble’s picture

pratik_kamble’s picture

Status: Needs work » Needs review
pratik_kamble’s picture

Issue tags: +GlobalContributionWeekend2020, +GCWIndia2020, +punedrupalgroup
C-Logemann’s picture

Issue tags: -GlobalContributionWeekend2020 +ContributionWeekend2020

Fixing issue tag to "ContributionWeekend2020“ as suggested on global event page.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

andypost’s picture

Issue summary: View changes

fixed summary

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed f737942 and pushed to 9.0.x, backported to 8.9.x

  • catch committed f737942 on 9.0.x
    Issue #3101138 by andypost, pratik_kamble, kishor_kolekar, alexpott:...

  • catch committed a658288 on 8.9.x
    Issue #3101138 by andypost, pratik_kamble, kishor_kolekar, alexpott:...
catch’s picture

Title: UpdateSettingsForm should call parent constructor » UpdateSettingsForm should not override parent constructor

Retrospective title change...

Status: Fixed » Closed (fixed)

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