Problem/Motivation

Basic Ads provides a settings form at /admin/config/system/basic-ads. The form saves configuration to basic_ads.settings.

The saved configuration includes:

- excluded_roles

However, the module does not provide a config/schema directory or schema for basic_ads.settings. As a result, the module's configuration cannot be fully validated by Drupal's config schema system.

Steps to reproduce

1. Install Drupal 11.4.
2. Install Basic Ads.
3. Go to: /admin/config/system/basic-ads
4. Select one or more roles under "Exclude roles from tracking".
5. Save the form.
6. Run: drush config:inspect --detail --only-error

Proposed resolution

Add config schema for basic_ads.settings.

Suggested schema shape:

basic_ads.settings:
  type: config_object
  label: 'Basic Ads settings'
  mapping:
    excluded_roles:
      type: sequence
      label: 'Excluded roles'
      sequence:
        type: string
        label: 'Role ID'

Comments

dkmishra created an issue. See original summary.

  • charlie59 committed 153acb3e on 1.4.x
    Issue #3609717 by dkmishra: Add config schema for basic_ads.settings...

  • charlie59 committed fe3a2f68 on 1.4.x
    Issue #3609717 by dkmishra: Fix yamllint errors in the new config files...
charlie59’s picture

Assigned: Unassigned » charlie59
charlie59’s picture

Status: Active » Fixed

Thanks for the report — fixed and released in 1.4.4.

You were right that basic_ads.settings had no schema; while adding it I found the block settings were undescribed too, so both are now covered in config/schema/basic_ads.schema.yml:

basic_ads.settings — excluded_roles as a sequence of role IDs, marked FullyValidatable. It also ships an install default now, so the object exists on a fresh install.
block.settings.basic_ads_advertisement_block — ad_placement_term (nullable integer) and count (integer). Any site with a placed ad block would have hit the same error.

Two stored values didn't match the shape a schema describes, so they're normalised in the same change:

excluded_roles was saving the raw #type: checkboxes return value — a map keyed by role ID ({editor: editor}) — where a sequence is a list. The form re-indexes on save now. Role matching compares values rather than keys, so old and new shapes behave identically at runtime; tracking was never affected.
ad_placement_term was saving the string entity_autocomplete returns ('3'), where the schema declares an integer. The block casts on save now, and stores NULL for an empty selection.

Existing sites are covered by basic_ads_update_8006() (re-index excluded_roles) and basic_ads_update_8007() (cast settings on existing block placements). Neither changes ad selection, rendering, or tracking, though config exports will show a diff.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

charlie59’s picture

Would appreciate a confirmation from your Drupal 11.4 environment that drush config:inspect --detail --only-error comes back clean after drush updb

dkmishra’s picture

Hi @charlie59, Thanks for committing the fix. I was wondering if you could consider adding issue credit for my contribution, since I reported the issue. I'd really appreciate it. Thank you!

Status: Fixed » Closed (fixed)

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