Problem/Motivation

Split from #2829919: Either avoid or explicitly test binary encoding in default configuration.

I found in #2829919: Either avoid or explicitly test binary encoding in default configuration that there's no policy on how to deprecated a config schema entry. This issue is a proposal for config schema deprecation policy.

Proposed resolution

  • Deprecated config schemas will expose a new key deprecated. The value is the deprecation message.
  • SchemaCheckTrait::checkValue() will check for this key and will trigger the deprecation error.
  • Next policy entry to be added to https://www.drupal.org/core/deprecation:

    Configuration schema

    Add a deprecated property in the deprecated config schema entry. The value should be the deprecation message. For example:

    complex_structure:
      type: mapping
      label: Complex
      deprecated: "The 'complex_structure' config schema is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use the 'complex' config schema instead. See http://drupal.org/node/the-change-notice-nid."
      mapping:
        key:
          type: ...
        ...
    
  • New deprecated property will be added, as last item, at https://www.drupal.org/node/1905070#properties:

Remaining tasks

Update https://www.drupal.org/core/deprecation document.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

A deprecated key with the deprecation message as value can now be used to deprecate a config schema.

Comments

claudiu.cristea created an issue. See original summary.

claudiu.cristea’s picture

Status: Active » Needs review
StatusFileSize
new4.11 KB

Here's the patch.

claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes
tstoeckler’s picture

For what it's worth I think this patch is great. Great idea to put this in the schema checker! Could use some more eyes before RTBC, though.

claudiu.cristea’s picture

Title: [policy proposal] Introduce a way to deprecate config schemas » [policy and patch] Introduce a way to deprecate config schemas
longwave’s picture

+++ b/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php
@@ -39,6 +40,8 @@ protected function setUp() {
+   * @expectedDeprecationMessage The 'complex_structure' config schema is deprecated in Drupal 8.7.x and will be removed in Drupal 9.0.x. Use the 'complex' config schema instead. See http://drupal.org/node/the-change-notice-nid.

Isn't this just @expectedDeprecation? I see two other uses of @expectedDeprecationMessage in core but don't see where this is actually handled.

claudiu.cristea’s picture

StatusFileSize
new4.17 KB
new2 KB

@longwave, good point, switched to @expectedDeprecation (I think @expectedDeprecationMessage does nothing).

pancho’s picture

Recategorized as Task, as we clearly need a mechanism to deprecate config schemata.

Re @expectedDeprecationMessage:
#2928645: \Drupal\Tests\migrate\Kernel\Plugin\MigrationDirectoryTest uses @expectedDeprecationMessage has a bit more on this. However, if @expectedDeprecationMessage really does nothing, then #2 should fail with the CI, shouldn't it?

claudiu.cristea’s picture

@Pancho, could you review this and RTBC or ask for changes?

claudiu.cristea’s picture

Issue tags: +@deprecated

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

penyaskito’s picture

Status: Needs review » Reviewed & tested by the community

Is this still feasible before 9.0.0?

I think we need this, and the proposal looks great.

During the 8.x lifecycle, has this even happened in core?
If it did, we would need a way to identify those and create child issues for deprecating them.

penyaskito’s picture

Tagging as Needs product manager review, as I guess it does.

catch’s picture

Version: 8.9.x-dev » 9.1.x-dev
Issue tags: -Needs product manager review

This doesn't need product manager review, it's just an API addition.

Would need to go into 9.1.x at this point. I kicked off a test against 9.1.x

Would be good to know if we have a use-case per #14.

catch’s picture

Title: [policy and patch] Introduce a way to deprecate config schemas » Introduce a way to deprecate config schemas
alexpott’s picture

Status: Reviewed & tested by the community » Active
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php
@@ -11,6 +11,8 @@
+ * @group legacy
+ *

+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php
@@ -17,6 +17,7 @@
+ * @group legacy

+++ b/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php
@@ -9,6 +9,7 @@
+ * @group legacy

Marking the whole test as legacy is wrong. We should not put config_schema_test.deprecated in install config. We should only create it in a specific legacy test.

The implementation looks fine. ONe thing I'm trying to work out is why you'd deprecate schema and not the config value itself... And once you've deprecated a specific config value what's the point of deprecating its schema? OTOH this might provide a nice way to deprecate config values and only have to add something to schema...

alexpott’s picture

Status: Active » Needs work
claudiu.cristea’s picture

@alexpott, in #2829919: Either avoid or explicitly test binary encoding in default configuration there's a use case that needs deprecating the schema. The configs are kept but with a new schema. So the old schema became stale

alexpott’s picture

@claudiu.cristea how does that actually work though? If the config is the same with the same keys then we can't have a deprecated schema pointing to a non-deprecated config value.

alexpott’s picture

Ah I see that issue suggests we need to deprecate a type tat might be used in many places...looking at that issue I'm not convinced it's the way to go. But I guess the use-case makes some sense.

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new6.26 KB
new3.92 KB

Fixing #18.

Status: Needs review » Needs work

The last submitted patch, 23: 2997100-23.patch, failed testing. View results

alexpott’s picture

It's best to not make the a module provide deprecated config.

  1. +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaDeprecationTest.php
    @@ -0,0 +1,33 @@
    +    $this->installConfig(['config_schema_deprecated_test']);
    

    Instead of installing config here we can write the configuration.

  2. +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaDeprecationTest.php
    @@ -0,0 +1,33 @@
    +    // A PHPUnit test requires at least one assertion to be performed.
    +    $this->assertTrue(TRUE);
    

    How about testing the expected config value. It's better than an assertTrue(TRUE).

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new2.71 KB
new3.71 KB

Thank you. Fixing #25.

penyaskito’s picture

#25 was taken care of.

We would need to add a change record and update https://www.drupal.org/node/1905070 docs, the later may be done after commit.

Needs something to be added to \Drupal\Core\TypedData\PrimitiveInterface or anywhere else? Or we just rely on d.org documentation?
Is there any kind of validation or could I add whatever key here? I'm already adding this 'deprecated' one even if it's not parsed, for example.

penyaskito’s picture

Status: Needs review » Reviewed & tested by the community

Answering my own question, schema doesn't have a meta-schema, so there's no need to add anything else.

alexpott’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record

@penyaskito config schema is definitely meta enough :)

It would be good to update some documentation somewhere - the docs in core.api.php feel too much of an overview. The suggested docs for the policy page are good. We definitely need a CR here (needs work for that). Also a small snippet for the release notes (see issue summary).

claudiu.cristea’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs change record

Added CR: https://www.drupal.org/node/3129881.

Added release notes snippet.

I will update the policy at https://www.drupal.org/core/deprecation as soon as is committed and will update also https://www.drupal.org/node/1905070 with a link to https://www.drupal.org/core/deprecation.

claudiu.cristea’s picture

Issue summary: View changes

Fixing also the example to be inserted in the deprecation policy documentation.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record

Thanks! This is a great idea.

This needs a CR too I think, as well as documentation somewhere in the codebase, like in an api.php group or such.

claudiu.cristea’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs change record

@xjm, but the CR has been already added in #30.

Regarding...

(...) documentation somewhere in the codebase, like in an api.php group or such.

Could you please elaborate? I have no idea where this could be documented more. As we'll document this in the Drupal core deprecation policy page and we have a CR, I think this should cover. I see no similar deprecation policy documented in an *.api.php group, but I might be wrong.

catch’s picture

Status: Reviewed & tested by the community » Needs review

I think this is a bit different to other deprecations because it's adding a new key to a YAML format. It looks to me like we could add this to https://www.drupal.org/docs/drupal-apis/configuration-api/configuration-...

claudiu.cristea’s picture

Issue summary: View changes

@catch, I've already mentioned that page to be updated, in #30. Now I've detailed that in IS. But I cannot update the docs pages until this is not approved/merged.

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC as per #35.

  • catch committed 0fb041f on 9.1.x
    Issue #2997100 by claudiu.cristea, alexpott, penyaskito, tstoeckler,...
catch’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +Needs followup

@claudiu.cristea sorry good point, that's a docs page and not api.drupal.org...

It might be worth a follow-up issue to move that documentation to an api.php somewhere, but yes we can't do that here.

Committed 0fb041f and pushed to 9.1.x. Thanks!

catch’s picture

Issue summary: View changes
andypost’s picture

Filed follow-up for config inspector #3168268: Display deprecated schema usage

claudiu.cristea’s picture

wim leers’s picture

Published https://www.drupal.org/node/3129881.

Well done everyone!

Status: Fixed » Closed (fixed)

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

quietone’s picture

Issue tags: -Needs followup
quietone’s picture

Issue tags: -policy, -@deprecated