Unable to get account ID from config

Created on 27 July 2023, over 1 year ago
Updated 28 August 2023, about 1 year ago

Problem/Motivation

When saving the config form for the module, hook_page_attachemnts (line 29) does not return the saved ID from the config.
If you dump out the config object, the ID exists correctly under `data` however, using `->get('id')` yields `null`

Steps to reproduce

Enable the module
Add an account ID into the `VWO Account ID` field at `/admin/config/system/vwo`
Save the form
View the front end of the site
Inspect the DOM
Search for 'vwo'
Nothing found

Proposed resolution

Strangely I have found that replacing line 28 (`$config = \Drupal::config('vwo.settings');`) with `$config = \Drupal::configFactory()->getEditable('vwo.settings');` does allow `$config->get('id')` to return the correct data from the object.
Both object have the correct ID data in the `data` property, but only the editable one is able to get to return the ID.

The other thing to note is that the immutable config does correctly pull back the other data that is stored, such as `filter` and `loading`, just not for `id`

🐛 Bug report
Status

Closed: won't fix

Version

1.3

Component

Code

Created by

🇬🇧United Kingdom james hawthorn-byng

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

Comments & Activities

  • Issue created by @james hawthorn-byng
  • Assigned to viren18febS
  • 🇮🇳India viren18febS

    Checking the issue!

  • Issue was unassigned.
  • 🇮🇳India viren18febS

    I have checked this issue in Drupal 9 & 10. after followed the Reproduce steps, I am able to get the 'vwo' in Inspect DOM & getting the id with this code. so we no need to change the code in hook_page_attachemnts().

    $config = \Drupal::config('vwo.settings');
      $id = $config->get('id');
  • Status changed to Needs review about 1 year ago
  • Status changed to Closed: won't fix about 1 year ago
  • 🇮🇳India keshavv India

    @James Hawthorn-Byng Not able to reproduce the issue. I am able to retrieve the ID from the configuration.
    The method mentioned in solution $config = \Drupal::configFactory()->getEditable('vwo.settings'); will provide the override config value that is written in the settings.php file.

Production build 0.71.5 2024