social_media_links_block is mising config schema so I'm attaching a patch including it.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

piggito created an issue. See original summary.

amrutalolage’s picture

Assigned: Unassigned » amrutalolage
amrutalolage’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new6.41 KB
new6.58 KB

Patch applied cleanly.
Tested, working fine.

amrutalolage’s picture

Assigned: amrutalolage » Unassigned
kirkkala’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.54 KB
new520 bytes

Good addition but the first patch did not make the services translatable using the string type. Attached a patch + interdiff to make all links translatable.

Translation of sequence is though slightly difficult and problematic and the attached patch only translates the link urls value and descriptions in the order of sequence, not the actual order..

vacho’s picture

This patch solving some problems with drush config:inspect

andypost’s picture

Status: Needs review » Needs work

#6 please provide interdiff

Needs work because "examples" are not a part of schema https://git.drupalcode.org/project/social_media_links/blob/8.x-2.x/src/P...

vacho’s picture

About the patch #5
I review and :
string: Human readable string that must be plain text and editable with a text field.
text: Human readable string that can contain multiple lines of text or HTML

At this documentation: https://www.drupal.org/docs/8/api/configuration-api/configuration-schema...
So patch 5 contemplate links into this fields and it seems well.

About the patch #6
I found some error about the types of fields so it does not solve really the problems with drush config:inspect
It is strange to me because 5 days ago I was sure that it works. but in really patch #1 and patch#5 works well and solve problems with drush config:inspect.

About the comment #7
I found that drush config:inspect need it to validate. The code shows that this is unset but it is on submit not on the build. Please explain a bit more the fault.

Removing examples from schema:
/var/www/html $ drush config:inspect --detail page_manager.page_variant.panels_everywhere
---------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------
Key Status
---------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------
page_manager.page_variant.panels_everywhere:variant_settings.blocks.fdc00696-a290-4810-9e39-8666dfc79467.iconset.installed_iconsets.fontawesome.examples missing schema
---------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------

oleksiy’s picture

Status: Needs work » Needs review

The last submitted patch (#6) fixes the missed schema for me. Thanks!

neslee canil pinto’s picture

Status: Needs review » Closed (duplicate)
piggito’s picture

Status: Closed (duplicate) » Needs review

@neslee-canil-pinto this isn't a duplicate cause the issue you referenced is only for field, formatter and widget while this one is for block settings.

vacho’s picture

Adding a suggestion key for appearance

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Both issues affect the same file, but let's get them both in

colin.eininger’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new4.85 KB
new4.76 KB

Hello,

I'm attaching a patch that adds translation capability to the block's schema. I thinks its important to let the user translates at least links and descriptions.

This adds a new data type to use the platform's name as label in the translation form (otherwise every platforms sections are called "Platform settings").

Please review these changes.

andypost’s picture

Not sure why you need typed data classes.

Just replace all string with text and that's it.

I see no reason to complicate it further

colin.eininger’s picture

StatusFileSize
new17.63 KB
new11.75 KB

I could replace string with label but every section would be called "Platform settings" which is really hard for an administrator to manage.

Here's a screenshot with label only :

without data type every sections are called "Platform settings" and we can't know which social media links we're editing

And with the data type :

Data type let us using platform name as sections label to improve the form

If there is an easier solution to this problem let me know !

sweetchuck’s picture

Status: Needs review » Needs work

1. When you create a new schema (or a complex data type) then its machine-name has to contain the machine-name of the module, to avoid name collision.
So the "platforms" should be "social_media_links.platform" or something like this.

2. I think there is an other solution to build a complex data without a custom PHP class.
Definition of the image_size.

Usage of the image_size

colin.eininger’s picture

1. I renamed the complex data type by "social_media_links.platform"

2. My first idea was to create a custom complexe type like the image_size :

platform_type:
  type: mapping
  mapping:
    value:
      type: label
      label: Value
    description:
      type: label
      label: Description
    weight:
      type: string
      label: Weight

Then defining each platform like that :

platform.contact:
  type: platform_type
  label: Contact
  
platform.twitter:
  type: platform_type
  label: Twitter

And finally using it :

block.settings.social_media_links_block:
  type: block_settings
  label: 'Social Media Links block'
  mapping:
    platforms:
      type: sequence
      label: Platforms
      sequence:
        type: platform.%key

With that solution :

Pros

  • No complex data type PHP class to maintain

Cons

  • We need to add each currently supported platform one by one
  • When adding a new platform, we need to add it to the schema
  • When editing a platform label we need to change it in the schema

With the php class :

Pros

  • Old platform are added automatically with their label
  • When adding a new platform, it automatically appears on the translation form with its label
  • When editing a platform, the change is automatically made on the translation form

Cons

  • Creation of a complex data type PHP class

I made the choice of a new PHP class to avoid further steps when adding/editing platforms. If that is not a problem but the php class is, we could use the image_size approach. The purpose being that the title of the section is clear.

guilhermevp’s picture

Status: Needs work » Needs review

I liked the solution with complex php class better, I believe is more straightforward for this module in particular, and since the platform class are simple, they are easy to manage as it is. Moving #18 to needs review as more people can vouch in. Also, the classes need to change names as #17 stated?

sweetchuck’s picture

The supported platforms are hard-coded anyways.

Keep in mind that there are tools that may use the configuration schema for static analysis of configuration files, like the string extractor for the localization system. Such systems won't work with dynamically defined configuration schemas.

colin.eininger’s picture

#20 you're right but the platform's name is defined as translatable in the plugin definition and should be targeted by the string extractor of the localization system. Then we're using the untranslated platform's name in the dynamically defined configuration and it should be translated (if I understood correctly this system).

dpacassi’s picture

Using #18 which fixed the "missing schema" errors.

phma’s picture

Status: Needs review » Needs work

I've been using #18 for a while, but now I'm getting an error trying to import the config.

In TypedConfigManager.php line 385:

  Invoking hook_config_schema_info_alter() has added (social_media_links.platforms) schema definitions  

phma’s picture

Status: Needs work » Needs review

I've opened a merge request with a small change to prevent hook_config_schema_info_alter from ever trying to add a new schema definition, which by design throws an Exception. As to why the social_media_links.platforms definition wasn't available in the first place, I don't know. All I did was sync the database from production and do a drush cim.

gquisini’s picture

Assigned: Unassigned » gquisini

I'll review this one

gquisini’s picture

Assigned: gquisini » Unassigned
StatusFileSize
new23.56 KB
new36.74 KB

I was trying to better understand what the role of the schema file is. According to doc, there are a few uses for the schema and the primary use case is for multiple language support. In an attempt to find something to validate, I installed the config_inspector module and it was shown as if everything was correct. I will attach some screenshots to comparison.

Sorry if my contribution was not very helpful, I will study a little more to better understand the use of the schema file.

lucassc made their first commit to this issue’s fork.

lucassc’s picture

I rebased the issue fork to prepare it to be merged into 8.x-2.x.

sophiavs’s picture

Assigned: Unassigned » sophiavs

I'll review :)

sophiavs’s picture

Assigned: sophiavs » Unassigned
Status: Needs review » Reviewed & tested by the community

I tested the functionalities of the module with the last commit and everything worked fine. I didn't saw any wrong schema. Passing to RTBC

tobiasb made their first commit to this issue’s fork.

tobiasb’s picture

fyi: The weight should be a integer and show_name a boolean. I fixes this already in the fork.

japerry’s picture

Status: Reviewed & tested by the community » Needs work

With #2898680: Missing config schema for field, widget and formatter committed, this likely needs a reroll. Also, would like to see some tests similar to the other issue before it gets committed.

ilya.no’s picture

I've been using patch, made from the MR, via https://git.drupalcode.org/project/social_media_links/-/merge_requests/1..., but after upgrading to D10.3.2 I've got error, as described in https://www.drupal.org/project/social_media_links/issues/3461790.

I haven't traced the issue, but it seems to be related to the solution with src/Plugin/Config/Schema/Platforms.php, because when I removed corresponding changes and added code from #12 patch, then the issue was gone.

I'm attaching a bit updated patch with several fixes in order to have ability for deploy.

I think, that issue's priority should be set to Critical, because currently it's not possible to import configuration.
In order to reproduce, need to create page manager variant and add "Social Media Links" block.

colin.eininger’s picture

I have created new drupal 10.2 and 10.3 instances, installed social_media_links module with the patch from MR!12. Added a block and exported the configuration. Then removed the block and imported the configuration.

Everything works as expected.

In order to troubleshoot your problem @ilya.no, can you describe all minimal step to reproduce ? In the other issue you said "Need to create page manager page". Is that the layout builder your refering to ?

colin.eininger’s picture

Assigned: Unassigned » colin.eininger

Ok, I wasn't on 10.3 during my tests. Tried again and reproducing the error. I'm looking at the issue rn.

colin.eininger changed the visibility of the branch 3023172-missing-config-schema to hidden.

colin.eininger changed the visibility of the branch 3023172-missing-config-schema to active.

colin.eininger’s picture

Assigned: colin.eininger » Unassigned
Status: Needs work » Needs review

I fixed the error on drupal 10.3.

When drupal retrieve a map key, it try to guess which type its parent's definition is and expect it to be either a MapDataDefinition or a SequenceDataDefinition.

We were using the ListDataDefinition which is unexpected. I switched our social_media_links.platforms type to use SequenceDataDefinition (which inherit from ListDataDefinition).

I tested the patch on drupal 10.2 and 10.3.

codebymikey’s picture

StatusFileSize
new5.78 KB

Attached static copy of the current MR.

codebymikey’s picture

wim leers’s picture

FYI, this is also causing a fatal error in #3578295: social_media_links' broken block plugin causes fatal error: unexpected error has occurred while fetching components.

Another bug is the absence of a correct ::defaultConfiguration() method — right now the default configuration is the fallback value [], which will trigger a PHP error for this block plugin's build() method.

wim leers’s picture

Status: Needs review » Needs work

NW for the other bug mentioned in #43.

tobiasb’s picture

Status: Needs work » Needs review

I added the missing default configuration, improved the config schema and some basic tests.