Add orderby key to all sequences in core

Created on 24 February 2017, over 7 years ago
Updated 15 April 2024, 2 months ago

Problem/Motivation

Follow-up to #2361539: Config export key order is not predictable for sequences, add orderby property to config schema β†’ . Sequences that are not sorted can result in unexpected configuration differences whilst importing configuration. Which confuses users because they are being told something is different when it is not. Also this behaviour can result in random test fails

Proposed resolution

We should add an orderby key to all configuration schema definitions in core, remove explicit sorting code, and test for the lack of an orderby in when we check that configuration matches the schema.

We might choose to file individual followup issues to do the remove explicit sorting code as this is likely to be something that needs to be considered on a case-by-case basis.

Remaining tasks

User interface changes

None

API changes

None.

Data model changes

All sequences in configuration sorted - this is likely to have an interesting upgrade path.

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
ConfigurationΒ  β†’

Last updated about 8 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States bradjones1 Digital Nomad Life

    So this is why I am still getting false-positive configuration diffs in my production deploys? I would have thought that #2361539: Config export key order is not predictable for sequences, add orderby property to config schema β†’ would have addressed this but this issue indicates to me there are some edge cases still remaining?

    The weird part to me is that on export in my local development environment, I can export and then do a drush cim and there are no changes. But deploy that same code to production and I get the same set of consistent config entities that appear changed but actually aren't.

    www-data@app-7947bcd569-rnz4j:~/html$ drush cim
    +------------+---------------------------------------------------------------------+-----------+
    | Collection | Config                                                              | Operation |
    +------------+---------------------------------------------------------------------+-----------+
    |            | commerce_product.commerce_product_variation_type.default            | Update    |
    |            | commerce_shipping.commerce_shipment_type.default                    | Update    |
    |            | core.entity_form_display.commerce_product_variation.default.default | Update    |
    |            | core.entity_view_display.commerce_product_variation.default.cart    | Update    |
    |            | core.entity_view_display.commerce_shipment.default.checkout         | Update    |
    |            | core.entity_view_display.commerce_shipment.default.user             | Update    |
    |            | search_api_solr.solr_field_type.text_en_6_0_0                       | Update    |
    |            | search_api_solr.solr_field_type.text_en_7_0_0                       | Update    |
    |            | search_api_solr.solr_field_type.text_und_6_0_0                      | Update    |
    |            | search_api_solr.solr_field_type.text_und_7_0_0                      | Update    |
    |            | views.view.commerce_cart_block                                      | Update    |
    |            | views.view.commerce_cart_form                                       | Update    |
    |            | views.view.commerce_carts                                           | Update    |
    |            | views.view.commerce_products                                        | Update    |
    |            | views.view.order_shipments                                          | Update    |
    +------------+---------------------------------------------------------------------+-----------+
    

    It's more noisy than anything but it would also be nice to have my CD logs only reflect actual changes. Or am I missing something here?

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Hunch: different PHP versions sort certain arrays differently? What PHP version are you using in prod vs local?

  • πŸ‡ΊπŸ‡ΈUnited States bradjones1 Digital Nomad Life

    Hi Wim, thanks for chiming in. This is containerized so everything "should" be the same and I just did a pull of my image locally to confirm and yes, same PHP versions locally and on production. I also thought perhaps the host environment was like, changing some sort of localization settings but I don't see any LC* environment variables... though I'm way out of my area of expertise there.

  • πŸ‡ΊπŸ‡ΈUnited States freelock Seattle

    I was looking into this for a few annoying instances in our sites, and am not finding PHP differences. I'm thinking perhaps database differences? SELECTs with no ORDER BY...

    We most often hit this issue on text format filters and static menu overrides. Today I'm seeing it on an entity_view_display layout builder settings.

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    I think this is going to need to be a plan because we really ought to add test coverage of everything.

    I propose to add a new method to ConfigEntityValidationTestBase (and perhaps also \Drupal\Tests\jsonapi\Functional\ConfigEntityResourceTestBase to test it in an end-to-end/integration test). That way we don't have to start from scratch.

    Most (but not all) type: sequence occurs in config entities anyway. For simple config, I think 🌱 [meta] Add constraints to all simple configuration Active is relevant.

  • πŸ‡³πŸ‡±Netherlands daffie

    I think that we should make sure that we have an database index for every query we add orderby().

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    @daffie Hah, I get that that triggered you but … it's completely unrelated πŸ˜… This is about \Drupal\Core\Config\Schema\SequenceDataDefinition::getOrderBy(), which is used only in \Drupal\Core\Config\StorableConfigBase::castValue(). It never relates to database queries.

  • πŸ‡³πŸ‡±Netherlands daffie

    @Wim Leers: Ok, than it is fine. Just want to make sure that Drupal does not get slower. :)

  • πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

    Could we start adding predictability, at least, to config entity dependencies? See ✨ Index configurations are changing from export to export. Closed: duplicate

Production build 0.69.0 2024