Fix the settings form

Created on 15 January 2025, about 1 month ago

Problem/Motivation

Currently the settings form can't be submitted. It results in a WSOD with a PHP error. This is caused by the changes that I made to the form as part of πŸ“Œ Invalidate cached pages when settings are updated Fixed . I was in a rush and wasn't being careful. I didn't properly implement the constructor so that it had the parent's signature and then called it.

Steps to reproduce

Try to submit the settings form at /admin/config/system/usfedgov_google_analytics.

Proposed resolution

Update the __construct() and create() functions to take the ConfigFormBase class' constructor into account.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dcam

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

Merge Requests

Comments & Activities

  • Issue created by @dcam
  • Merge request !17Fix the settings form β†’ (Merged) created by dcam
  • πŸ‡ΊπŸ‡ΈUnited States dcam

    For the record, adding the $typedConfigManager type hint resulted in this error in D10.4.1:

    PHP Fatal error: Type of Drupal\usfedgov_google_analytics\Form\UsfedgovGoogleAnalyticsForm::$typedConfigManager must not be defined (as in class Drupal\Core\Form\ConfigFormBase) in /var/www/html/web/modules/contrib/usfedgov_google_analytics/src/Form/UsfedgovGoogleAnalyticsForm.php on line 15

    I know there was an issue with how core implemented this new ConfigFormBase parameter. I'm not yet certain if this will cause an issue with supporting D10 and D11 with the same version.

  • πŸ‡ΊπŸ‡ΈUnited States dcam

    The settings form class's constructor could not support both D10 and D11 as it was written.

    The pattern I've implemented instead is useful for isolating a class from upstream changes. You aren't trying to override the parent's constructor anymore, so if it changes then you don't have to care or do anything, at least not in the short term. The downside is that the code is uglier because you have to add more boilerplate in the form of property declarations and setter functions.

  • Pipeline finished with Skipped
    about 1 month ago
    #396971
  • πŸ‡ΊπŸ‡ΈUnited States dcam

    Releasing this in version 2.2.1.

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

Production build 0.71.5 2024