Settings form 'Add another ID' error: Undefined variable 'accounts'

Created on 8 December 2021, about 3 years ago
Updated 6 July 2023, over 1 year ago

Problem/Motivation

When clicking the 'Add another ID' button in the settings form, an AJAX error is reported: 'Undefined variable: accounts in /(...)/google_analytics/src/Form/GoogleAnalyticsAdminSettingsForm.php on line 145'.

Proposed resolution

Attached patch assigns $accounts variable outside the $id_count === NULL check. Also, using the (string) cast for $accounts[$i] if it's not set reports an 'Undefined offset' notice if $accounts is empty (but $id_count is force-set to 1) - even with the null coalescing operator. Patch expands this usage to include an isset() check.

πŸ› Bug report
Status

Closed: won't fix

Version

4.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada bgilhome Victoria

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States japerry KVUO

    This part of the code is unfortunately a bit brittle. However, it was fixed/improved in the latest Google tag (2.0.3) module.

Production build 0.71.5 2024