Config schema references incorrect properties

Created on 3 February 2025, about 2 months ago

Problem/Motivation

https://git.drupalcode.org/project/advban/-/blob/91fca0f7521613996826122...

Is a config schema that was added in https://git.drupalcode.org/project/advban/-/commit/6427cba1dc0b041da8ed9... that didn't reference any issue etc.

The properties of the scheme defined don't match those saved by the config form in the config form: https://git.drupalcode.org/project/advban/-/blob/91fca0f7521613996826122... and in other places in the module.

Steps to reproduce

Proposed resolution

Change the property names in the newly added config schema to match those used by the module.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom steven jones

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

Comments & Activities

  • Issue created by @steven jones
    • acee31b1 committed on 8.x-1.x
      Issue #3503989: Config schema references incorrect properties
      
  • πŸ‡ΊπŸ‡¦Ukraine goodboy Kharkiv, Ukraine

    @steven jones, thank you for your report.

  • πŸ‡¬πŸ‡§United Kingdom steven jones

    Woah! https://git.drupalcode.org/project/advban/-/commit/acee31b11c1aa9be5dc39... is going to break all existing installs, if you want to rename your config keys like that you're going to need to provide a migration path for existing installs.

    I'd was advocating for changing the contents of advban.schema.yml to match the existing names.

    • 21926211 committed on 8.x-1.x
      Issue #3503989: Config schema references incorrect properties
      
  • πŸ‡ΊπŸ‡¦Ukraine goodboy Kharkiv, Ukraine

    @steven jones, I changed the schema. Please, review

  • πŸ‡¬πŸ‡§United Kingdom steven jones

    @goodboy the naming looks better, thanks. Looks like the type of the expiry_durations property isn't correct, I think it should be 'string' not a 'text' because it's not translateable?

  • πŸ‡ΊπŸ‡¦Ukraine goodboy Kharkiv, Ukraine

    @steven jones, I use "text" because the expiration date can potentially be longer than 255 characters.

  • πŸ‡¬πŸ‡§United Kingdom steven jones

    @goodboy I don't think the 'string' type imposes a length limit, though might be wrong about that! What makes you think it has a length limit?

  • πŸ‡ΊπŸ‡¦Ukraine goodboy Kharkiv, Ukraine

    @steven_jones, I use '#type' => 'textfield' and '#type' => 'textarea' for form fields and correspond them to schema fields as 'textfield' => 'string', 'textarea' => 'text'. The textfield type has limitation 255 chars.

    I consider the expiry_durations field like a description and I found core schemas use 'text' type for descriptions. So, I think the field can be left 'text' type. Perhaps the type 'string' can also be used but I prefer don't change anything if I can.

    I also asked AI for differences between 'string' and 'text' schema types.
    "In Drupal, both string and text are data types used for storing textual data, but they serve different purposes and have distinct characteristics. Here's a breakdown of the differences:
    1. string Type
    Purpose: Used for short, simple text values.
    Storage: Typically stored in the database as a VARCHAR with a limited length (e.g., 255 characters by default in Drupal).
    2. text Type
    Purpose: Used for longer, more complex text values that may include formatting or multiple lines.
    Storage: Stored in the database as a TEXT field, which can hold much larger amounts of data compared to VARCHAR."

    Honestly, I don't know how right this is. But I think something like that.

  • πŸ‡¬πŸ‡§United Kingdom steven jones

    Thanks for your response, but I think you've managed to research the Database Schema, rather than the Config Schema I think?

    I searched for a relevant example in Drupal core, and I think the most comparable thing to a big lump of text is the request path condition plugin in the block system, i.e. this:

    The config schema for that plugin is this:

    condition.plugin.request_path:
      type: condition.plugin
      mapping:
        pages:
          type: string
    

    I.e. a string, like I'm suggesting you should use too.

    The main trait of the text type is that it specifies that the content is translatable, which is weird for this use-case.

    So, I think it should be string.

    In theory, if you wanted to change the data model, then you could store the data as an array of durations, rather than a string that gets exploded/imploded etc. but that's probably another issue :)

    • 9db141e3 committed on 8.x-1.x
      Issue #3503989: Config schema references incorrect properties
      
  • πŸ‡ΊπŸ‡¦Ukraine goodboy Kharkiv, Ukraine

    @steven jones, I have changed the type of the field, as you said. Thank you

  • πŸ‡¬πŸ‡§United Kingdom steven jones

    Thanks, the config schema issues raised in my original OP have been sorted.

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

Production build 0.71.5 2024