Problem/Motivation

If a config entity is being renamed through \Drupal\Core\Config\ConfigFactoryInterface::rename() then it becomes impossible to load the entity by its uuid through \Drupal\Core\Entity\EntityRepositoryInterface::loadEntityByUuid().

Proposed resolution

When config is saved or deleted we listen to the corresponding events in \Drupal\Core\Config\Entity\Query\QueryFactory and update the config key store for fast lookups so that a config entity could be loaded by its lookup keys.

In order to cover renaming config entities through the config factory we should additionally listen to config renaming events and update the config key store for fast lookups accordingly. Additionally we should remove delete the old values from the config key store for fast lookups.

Remaining tasks

Review
Commit

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#82 reroll_diff_77-82.txt1.28 KBtanuj.
#82 2960643-82.patch9.77 KBtanuj.
#77 interdiff_69-77.txt2.3 KBsourabhjain
#77 2960643-77.patch9.74 KBsourabhjain
#74 interdiff_2960643_71-74.txt5.38 KB_pratik_
#74 2960643-74.patch12.4 KB_pratik_
#73 interdiff_71-73.txt3.31 KBakram khan
#73 2960643-73.patch11.13 KBakram khan
#71 2960643-69-71.txt1.33 KBamanshukla6158
#71 2960643-71.patch8.85 KBamanshukla6158
#69 interdiff_2960643_67-69.txt2.31 KB_pratik_
#69 2960643-69.patch9.74 KB_pratik_
#67 2960643-67.patch7.33 KB_utsavsharma
#64 2960643-64.patch9.78 KBranjith_kumar_k_u
#59 interdiff_55-59.txt1.12 KBmegha_kundar
#59 2960643-59.patch9.79 KBmegha_kundar
#55 interdiff_52-55.txt1.16 KBnikitagupta
#55 2960643-55.patch16.39 KBnikitagupta
#54 interdiff_53-54.txt607 bytesnikitagupta
#54 2960643-54.patch16.3 KBnikitagupta
#52 2960643-52.patch16.35 KBanushrikumari
#51 2960643-51.patch16.33 KBanushrikumari
#43 2960643-43.patch16.42 KBjohnwebdev
#41 interdiff-40-41.txt5.32 KBgease
#41 2960643-41.patch16.58 KBgease
#40 interdiff-38-40.txt7.38 KBgease
#40 2960643-40.patch15.92 KBgease
#38 interdiff-35-38.txt1.47 KBgease
#38 2960643-38.patch14.25 KBgease
#35 2960643-35-interdiff.txt7.34 KBberdir
#35 2960643-35.patch14.25 KBberdir
#26 2960643-25.patch16.04 KBgease
#25 interdiff-23-25.txt6.13 KBgease
#25 2960643-23.patch10.38 KBgease
#23 interdiff-20-23.txt3.18 KBgease
#23 2960643-23.patch10.38 KBgease
#20 2960643-20_.patch10.47 KBtstoeckler
#20 2960643-18-20-interdiff.txt2.31 KBtstoeckler
#18 2960643-18.patch10.9 KBtstoeckler
#18 2960643-17-18-interdiff.txt910 byteststoeckler
#17 2960643-17.patch10.47 KBanya_m
#11 interdiff-8-11.txt3.43 KBhchonov
#11 2960643-11.patch10.46 KBhchonov
#8 interdiff-7-8.txt935 byteshchonov
#8 2960643-8.patch7.72 KBhchonov
#7 interdiff-4-6.txt1.58 KBhchonov
#7 2960643-6.patch7.66 KBhchonov
#4 interdiff-3-4.txt1.49 KBhchonov
#4 2960643-4.patch7.66 KBhchonov
#3 interdiff-2-3.txt4.07 KBhchonov
#3 2960643-3.patch6.07 KBhchonov
#2 2960643-2-test-only.patch1.62 KBhchonov

Comments

hchonov created an issue. See original summary.

hchonov’s picture

StatusFileSize
new1.62 KB
hchonov’s picture

StatusFileSize
new6.07 KB
new4.07 KB

Test + fix. I am not sure if we need an update path to update the config key store for all config entities, as if there is a system where a config entity has been renamed then that entity will not be loadable by its entity UUID.

hchonov’s picture

StatusFileSize
new7.66 KB
new1.49 KB

And here is the update for re-saving all entities that cannot be loaded by uuid.

hchonov’s picture

Issue summary: View changes
amateescu’s picture

Status: Needs review » Needs work
+++ b/core/modules/system/system.post_update.php
@@ -130,3 +131,28 @@ function system_post_update_change_delete_action_plugins() {
+function system_post_update_resave_non_loadable_config_entities() {

We should use the new config.entity_updater service instead of manually re-saving all config entities :) See https://www.drupal.org/node/2949630

hchonov’s picture

Status: Needs work » Needs review
StatusFileSize
new7.66 KB
new1.58 KB

I wasn't sure if that service could be used for more entity types at once. Lets give it a try :).

Do we need an update test?

Oups I've used the wrong comment number for the patch .. sorry about this.

hchonov’s picture

StatusFileSize
new7.72 KB
new935 bytes

Oh wait the CR contains the wrong guide. There is no service for the config entity updater like stated in the CR, but the class resolver should be used instead.

hchonov’s picture

The last submitted patch, 7: 2960643-6.patch, failed testing. View results

hchonov’s picture

StatusFileSize
new10.46 KB
new3.43 KB

After looking further into the issue I've found out, that it is not enough to simply re-save the entities, as by doing only this the new name will be added to the values in the corresponding record in the key value store for fast lookups. This solves the problem, but the previous name remains there as well, which should be removed. We could automate this for records containing only one entry as then we know that this is the entry written by us and contains only the previous name. If the record however contains multiple entires, then we should not automatically just remove it, but instead inform that manual work is needed.

tstoeckler’s picture

Wow, absolutely crazy find and really nice fix. The new code fits really neatly in with the existing code - very unfortunate that we forgot to put it there in the first place.

Some notes:

  1. +++ b/core/modules/system/system.post_update.php
    @@ -130,3 +132,70 @@ function system_post_update_change_delete_action_plugins() {
    +            if ($lookup_key === 'uuid') {
    ...
    +                // If the values contain more than one record then there is
    +                // custom code which is adding information to the records and
    +                // we cannot simply delete that information. Instead we inform
    +                // of the problem.
    +                else {
    +                  \Drupal::logger('system')
    +                    ->warning('Because of an error by renaming config entities a record in key value store for fast lookups still contains the previous name of the config entity. As there are multiple entries in the record it could not be cleaned automatically and requires your attention. Please take a look at the record with the name %record in the key value store for the collection %collection.', [
    +                      '%record' => $key,
    +                      '%collection' => $query_factory::CONFIG_LOOKUP_PREFIX . $entity_type_id
    +                    ]);
    +                }
    

    So if we only clean-up the UUID ones I think we can simplify the update path and simpy query the key-value store directly for items in the "config.entity.key_store.$entity_type_id" collection with the name/key "uuid:$entity_uuid".

    I am wondering, though, why we do are not updating the other keys, as well? All that is stored is the ID, so regardless of the actual keys, we know what we have to update, right?

    Having written that, it seems to me that - even if we do update all possible keys - we should be able to perform the update without using reflection, by first building up a map of renames using the loadEntityByUuid() check just like you are doing now and then in a second step iterating over all values in "config.entity.key_store.$entity_type_id" key-value collection and replacing any IDs that match our rename map.

    What do you think?

  2. +++ b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
    @@ -109,6 +109,31 @@ protected function setUp() {
    +  public function testLoadByUuidAfterRename() {
    

    I think this test could be added to ::testLookupKeys() instead, no? We already test the save and delete event there, so I think that would make sense.

tstoeckler’s picture

+++ b/core/modules/system/system.post_update.php
@@ -130,3 +132,70 @@ function system_post_update_change_delete_action_plugins() {
+ * Re-saves config entities that cannot be loaded by uuid.
...
+ * By re-saving the entities that cannot be loaded by uuid the config key store
+ * for fast lookups will be updated, which will make the entities loadable by
+ * uuid.

uuid -> UUID

Also, instead of having the longer description in the docblock, let's remove it there and add it as in inline comment in the function. The docblock will be parsed and displayed when running the updates via update.php and updates with multi-line descriptions always look pretty weird there.

hchonov’s picture

So if we only clean-up the UUID ones I think we can simplify the update path and simpy query the key-value store directly for items in the "config.entity.key_store.$entity_type_id" collection with the name/key "uuid:$entity_uuid".

Sure, we could do that. I just felt more comfortable using the code that we already have.

I am wondering, though, why we do are not updating the other keys, as well? All that is stored is the ID, so regardless of the actual keys, we know what we have to update, right?

You mean if the config entity has additional look-up keys beside the uuid key? I think you are right and we should cover them as well. Good catch!

Having written that, it seems to me that - even if we do update all possible keys - we should be able to perform the update without using reflection, by first building up a map of renames using the loadEntityByUuid() check just like you are doing now and then in a second step iterating over all values in "config.entity.key_store.$entity_type_id" key-value collection and replacing any IDs that match our rename map.

How do you build a rename map with only one known value? The original ID is already lost and there is no track of it.

I think this test could be added to ::testLookupKeys() instead, no? We already test the save and delete event there, so I think that would make sense.

Yes, this makes more sense.

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

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tstoeckler’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Needs a re-roll for System post-updates added in the meantime.

anya_m’s picture

Issue tags: -Needs reroll
StatusFileSize
new10.47 KB

Reroll for #11 patch for 8.7.x

tstoeckler’s picture

Status: Needs work » Needs review
StatusFileSize
new910 bytes
new10.9 KB

Status: Needs review » Needs work

The last submitted patch, 18: 2960643-18.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tstoeckler’s picture

Status: Needs work » Needs review
StatusFileSize
new2.31 KB
new10.47 KB

Ahh sorry, I accidentally included #3005137: Register the node/add path as link template "add-page" in #18. Reverted that and also fixed the coding style violations.

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.

gease’s picture

StatusFileSize
new10.38 KB
new3.18 KB

Some updates to the post_update hook implementation. As is noticed in #14, what stands for uuid, stands for other keys as well (in core, I can see just uuid and theme). So I removed uuid condition. Entity updater should care to re-save unloadable entities, and it saves those for which updater callback returns TRUE, so we need to negate $loadable.

Status: Needs review » Needs work

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

gease’s picture

StatusFileSize
new10.38 KB
new6.13 KB

Extended test with checks that renaming config object through Entity API works correctly (including removing obsolete entries from key-value store) and added upgrade path test reproducing renaming config object both through Entity API and Config API.
The test failure in #23 still needs to be taken care of.

gease’s picture

StatusFileSize
new16.04 KB

Erroneously uploaded previous patch before.

berdir’s picture

  1. +++ b/core/lib/Drupal/Core/Config/ConfigRenameEvent.php
    @@ -21,10 +28,13 @@ class ConfigRenameEvent extends ConfigCrudEvent {
        *   The old configuration object name.
    +   * @param \Drupal\Core\Config\Config $old_config
    +   *   (optional) The configuration before it has been renamed.
        */
    -  public function __construct(Config $config, $old_name) {
    -    $this->config = $config;
    +  public function __construct(Config $config, $old_name, $old_config = NULL) {
    +    parent::__construct($config);
         $this->oldName = $old_name;
    +    $this->oldConfig = $old_config;
       }
     
    

    You can still add a type hint while keeping it optional. Not sure if not passing it should be deprecated so that we can eventually make it required (has to be in D10 now)

  2. +++ b/core/lib/Drupal/Core/Config/ConfigRenameEvent.php
    @@ -37,4 +47,14 @@ public function getOldName() {
    +   * Gets the old configuration object.
    +   *
    +   * @return \Drupal\Core\Config\Config
    +   *   The configuration object the renaming of which caused the event to fire.
    +   */
    +  public function getOldConfig() {
    +    return $this->oldConfig;
    

    Because this doesn't document a NULL return value, so it is kind of expected to be there, and we can't provide BC for it.

    Maybe we should just require it? The classname is hardcoded, this isn't a service, there is no reason for it to be subclassed.

  3. +++ b/core/modules/system/system.post_update.php
    @@ -140,6 +141,71 @@ function system_post_update_change_delete_action_plugins() {
    + * Re-saves config entities that cannot be loaded by uuid.
    + *
    + * By re-saving the entities that cannot be loaded by uuid the config key store
    + * for fast lookups will be updated, which will make the entities loadable by
    + * uuid.
    + */
    +function system_post_update_resave_non_loadable_config_entities(&$sandbox = NULL) {
    

    not sure if the second paragraph is needed and afaik both drush and the UI don't display that properly.

  4. +++ b/core/modules/system/system.post_update.php
    @@ -140,6 +141,71 @@ function system_post_update_change_delete_action_plugins() {
    +  $entity_types = $entity_type_manager->getDefinitions();
    +  foreach ($entity_types as $entity_type_id => $entity_type) {
    +    if ($entity_type instanceof ConfigEntityTypeInterface) {
    +      $config_entity_updater->update($sandbox, $entity_type_id, function ($entity) {
    +        /** @var \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository */
    +        $entity_repository = \Drupal::service('entity.repository');
    +        $entity_type = $entity->getEntityType();
    

    I don't think this foreach loop works like you think it should.

    The trick with the config entity update and $sandbox is that is going to do updates in batch and is going to be called many times. But your loop is going to start from the start every time.

    We likely can't use that service here but need to duplicate that logic, it does too much on its own.

    I think it is likely much easier to implement if you instead loop over *all* config and don't use entity API here.

    That means we need to use $config_factory->listAll() and then probably use array_chunk to split them into chunks of e.g. 100, put that in sandbox (unfortunately makes it quite big as there can be thousands and then each call needs to process one chunk, remove it and return. And then #finished = 1.

    And for each config, you use similar logic as the rename event implementation and interact with the key value service directly.

hchonov’s picture

Re #27.1-3:
Agree with everything.

Re #27.4:

I don't think this foreach loop works like you think it should.

The trick with the config entity update and $sandbox is that is going to do updates in batch and is going to be called many times. But your loop is going to start from the start every time.

Hm, to be honest I am confused :).

Please take a look at text_post_update_add_required_summary_flag():
it has at the end

$config_entity_updater->update($sandbox, 'entity_form_display', $widget_callback);
$config_entity_updater->update($sandbox, 'field_config', $field_callback);

Which is basically also like a foreach isn't it?

berdir’s picture

Yeah, I'm not 100% sure, I see that there is a $sandbox_key and it's done inside of that, but the global #finished is then set based on the current key. So honestly, I don't know what is going to happen exactly? Probably the last call wins, so it would process $batch_size of each entity type, and then if the last one has less than $batch_size, it would be done. And if not, then would continue until the last one is done.

So, it *kinda* works I suppose as long has the last entity type has the highest entity count? which is obviously not something that you can rely on.

hchonov’s picture

but the global #finished is then set based on the current key. So honestly, I don't know what is going to happen exactly? Probably the last call wins, so it would process $batch_size of each entity type, and then if the last one has less than $batch_size, it would be done. And if not, then would continue until the last one is done.

So, it *kinda* works I suppose as long has the last entity type has the highest entity count? which is obviously not something that you can rely on.

Yes, the last one will always win.

So we just found a bug when the config entity updater is being used for multiple entity types. In this case the #finished should be computed based on all sandbox keys. This also means that text_post_update_add_required_summary_flag() will not update all entity_form_display entities if there are less field_config entities.

berdir’s picture

> In this case the #finished should be computed based on all sandbox keys

Which is easier said than done because update() has no knowledge about which keys even exist and it doesn't know in advance how many that there are.

Maybe we could add a key inside that's basically a config_entity_updater_was_here flag, then it can loop over all sandbox keys with that key, and then each run stores its own progress and calculates the total progress of all that did run so far. As it also doesn't know if it's the last. Plus a check that just skips if the current sandbox_key is already complete (except updating total). Still quite a bit of overhead and complexity.

Which is why I think that a custom batch loop that just loops over all config directly would be easier here.

hchonov’s picture

Which is easier said than done because update() has no knowledge about which keys even exist and it doesn't know in advance how many that there are.

Maybe we could add a key inside that's basically a config_entity_updater_was_here flag, then it can loop over all sandbox keys with that key, and then each run stores its own progress and calculates the total progress of all that did run so far. As it also doesn't know if it's the last. Plus a check that just skips if the current sandbox_key is already complete (except updating total). Still quite a bit of overhead and complexity.

It can be a lot easier - just put the sandbox keys into a dedicated section :).
So instead of $sandbox[$sandbox_key] use $sandbox['sandbox_keys'][$sandbox_key]. Then we know that we simply have to iterate through everything that is inside $sandbox['sandbox_keys'].

I think that we would need a dedicated issue for that, where we will have to rerun the updates updating multiple config entity types.

hchonov’s picture

I've created an issue for this - #3092714: Config entity updater misbehaves when updating multiple entity types. Let's continue the discussion about this over there and focus on #27.1-3 here.

berdir’s picture

Assigned: Unassigned » berdir

Going to have a look at this.

berdir’s picture

Assigned: berdir » Unassigned
Status: Needs work » Needs review
StatusFileSize
new14.25 KB
new7.34 KB

So, here's my proposal for an update function that is much simpler and IMHO sufficient here as in at least as good as the other, faster and doesn't have any problematic assumptions:

* The entity type fail is I think because that entity type hasn't been installed yet, we can't rely on that being the case. My approach doesn't have this problem because the only thing we need from a config is its entity type id, that's always going to be available if there's config for it.
* I honestly didn't fully understand the logic around having one or multiple entries and that warning log message. One one side, we IMHO do not need to support any third party messing with the data, this is private. So UUID must always be exactly one key. However, at the same time, it is perfectly valid for other lookup keys to have many values, one example is blocks with the theme lookup key.

So my update function relies on the expectation that UUID must be exactly one config name, and if it doesn't match that, we delete that and resave it. That's enough to fix both conditions in the test.

What it would *not* clean up is exactly that example with block themes, so doing an entity query on a block theme would still return stale keys, but that's less of an issue as they are expected to be passed to loadMultiple() which would then just ignore non-existing keys. Might be a small overhead, but the cached config storage explicitly supports caching non-existing lookups as well, so that's very minimal.

If we'd decide to have to fix that too, then we should probably switch the the test from image styles to blocks.

There's two things that I'm not quite sure about in the update test:
* Many comments explain what "we" do. I think that's not really how we comment things, should be more neutral and just explains how things are. Too tired to try and rewrite that.
* We're using the entity API before running updates. It's "just" config entities, so less tricky, but still, that's not really supported We've had problems with that before, if we'd add some kind of new lookup/check relying on things that aren't there yet... We're only testing our own mock data, so I'm not sure how important is.

Status: Needs review » Needs work

The last submitted patch, 35: 2960643-35.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

berdir’s picture

Status: Needs work » Needs review
gease’s picture

StatusFileSize
new14.25 KB
new1.47 KB

Updated database dump from 8.4 to 8.8.

hchonov’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/system/tests/fixtures/update/drupal-8.non-loadable-config-entities.php
    @@ -0,0 +1,22 @@
    +
    +
    

    Let's keep only one empty line and also document this. Maybe something like:

    Add an UUID lookup record containing the previous and the new name of a config entity, which simulates what used to happen prior to Drupal 8.9.0 after renaming a config entity through the config factory.

  2. +++ b/core/modules/system/tests/src/Functional/Update/NonLoadableConfigEntitiesUpdateTest.php
    @@ -0,0 +1,73 @@
    +   * Test resave system_post_update_resave_non_loadable_config_entities().
    

    Let's describe what we are testing and add a see to the update method.

  3. +++ b/core/modules/system/tests/src/Functional/Update/NonLoadableConfigEntitiesUpdateTest.php
    @@ -0,0 +1,73 @@
    +
    

    not needed empty line.

  4. +++ b/core/modules/system/tests/src/Functional/Update/NonLoadableConfigEntitiesUpdateTest.php
    @@ -0,0 +1,73 @@
    +
    

    Not needed empty line.

  5. +++ b/core/modules/system/tests/src/Functional/Update/NonLoadableConfigEntitiesUpdateTest.php
    @@ -0,0 +1,73 @@
    +    // We changed config entity id and renamed config accordingly, simulating
    +    // result of calling Config::set() on config object id
    +    // and ConfigFactory::rename().
    +    // We make sure that config entity is loadable by its name but not
    +    // by its uuid.
    

    Refactor comment to use the empty space.

  6. +++ b/core/modules/system/tests/src/Functional/Update/NonLoadableConfigEntitiesUpdateTest.php
    @@ -0,0 +1,73 @@
    +    // We check that now the config entity that was renamed with Config API can
    

    don't need the "we".

  7. +++ b/core/modules/system/tests/src/Functional/Update/NonLoadableConfigEntitiesUpdateTest.php
    @@ -0,0 +1,73 @@
    +    // Here we check if the obsolete entry was removed from key-value store.
    

    "here we" is also unnecessary.

  8. +++ b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
    @@ -116,6 +116,46 @@ protected function setUp() {
    +    // Ensure that the entity is loaded by its uuid.
    

    ...entity can be loaded..

gease’s picture

Status: Needs work » Needs review
StatusFileSize
new15.92 KB
new7.38 KB

Added test checks for correctness of value in lookup table and extensively reworked comments to make clear there are 2 separate use cases which are tested on separate entities and fixtures.

gease’s picture

StatusFileSize
new16.58 KB
new5.32 KB

Further updated fixtures and comments for the sake of clarity and consistency.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

johnwebdev’s picture

StatusFileSize
new16.42 KB

Rerolled.

johnwebdev’s picture

Issue tags: +Bug Smash Initiative
larowlan’s picture

+++ b/core/lib/Drupal/Core/Config/ConfigRenameEvent.php
@@ -21,10 +28,13 @@ class ConfigRenameEvent extends ConfigCrudEvent {
+  public function __construct(Config $config, $old_name, Config $old_config) {

Do we need to allow this to be null for BC (And trigger a deprecation if it is not provided)?

It is possible that someone in contrib/custom code is firing their own config events right?

If so we'd also need a deprecation test

berdir’s picture

See #27 for why I think BC for this is pointless. The event must provide the old config or we can't fix the bug. Only mentions of this class are on the event subscribers: http://grep.xnddx.ru/search?text=ConfigRenameEvent

larowlan’s picture

Fair enough - thanks

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

quietone’s picture

Issue summary: View changes
Issue tags: +Needs reroll, +Novice

Needs reroll and looks suitable for a novice.

anushrikumari’s picture

Assigned: Unassigned » anushrikumari
anushrikumari’s picture

Assigned: anushrikumari » Unassigned
StatusFileSize
new16.33 KB

Rerolled patch for 9.2.x

anushrikumari’s picture

StatusFileSize
new16.35 KB

Status: Needs review » Needs work

The last submitted patch, 52: 2960643-52.patch, failed testing. View results

nikitagupta’s picture

Status: Needs work » Needs review
StatusFileSize
new16.3 KB
new607 bytes
nikitagupta’s picture

StatusFileSize
new16.39 KB
new1.16 KB
kapilv’s picture

Issue tags: -Needs reroll
amateescu’s picture

+++ b/core/lib/Drupal/Core/Config/ConfigRenameEvent.php
@@ -37,4 +47,14 @@ public function getOldName() {
+  public function getOldConfig() {

The entity API uses the term "original" when referring to the object that holds the previous values. Is there any reason to go with "old" here?

I see we use "old name" when referring to the previous name, but I'm not sure being consistent with that is worth it in the long run..

renatog’s picture

Status: Needs review » Needs work

On this case we're using $this_model
$old_config = $this->get($old_name);

And here we're using $thisModel

protected $oldConfig;

Both are correct but we can use one or another in the same file to be consistent

More information here:
https://www.drupal.org/docs/develop/standards/coding-standards#naming

megha_kundar’s picture

Status: Needs work » Needs review
StatusFileSize
new9.79 KB
new1.12 KB

Converted $old_config to $oldConfig as per coding standards.

berdir’s picture

> Both are correct but we can use one or another in the same file to be consistent

Actually, the not-mixing part refers to local variables only. properties must camelCase. local variables can be either but should be consistent across the whole file. And since there are existing variables that use snake_case, #58/#59 isn't correct.

#57: Hm. the existence of $old_name is exactly why old_config made sense to me, but I have no strong feelings about that. Interestingly, https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Config%21... already does exist, that does make we wonder if we could rely on that instead, then we wouldn't even need the extra argument?

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ranjith_kumar_k_u’s picture

StatusFileSize
new9.78 KB

Rerolled #59 for 9.5

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

gaurav-mathur’s picture

Patch #64 applied successfully on drupal version 9.5.x and working fine but this patch does not applied on drupal version 10.1.x please reroll the patch for drupal 10.1.x

Thank you

_utsavsharma’s picture

StatusFileSize
new7.33 KB

Rerolled for 10.1.x.
But i could not understand how to make changes in the file (core/modules/system/system.post_update.php).
Please review.

catch’s picture

Status: Needs review » Needs work

This needs the post update adding back from #64. You should be able to just copy the code over from the patch as a last resort given it's all new.

_pratik_’s picture

Status: Needs work » Needs review
StatusFileSize
new9.74 KB
new2.31 KB

Add changes in system.post_update.php also.
thanks

renatog’s picture

Issue summary: View changes
Status: Needs review » Needs work
+++ b/core/modules/system/system.post_update.php
@@ -93,3 +94,41 @@ function system_post_update_timestamp_formatter(array &$sandbox = NULL): void {
+  foreach ($config_factory->loadMultiple($config_names) as $name => $config) {
+    $entity_type_id = $config_manager->getEntityTypeIdByName($name);
+    if ($entity_type_id) {
+      $key_value_store = \Drupal::keyValue(QueryFactory::CONFIG_LOOKUP_PREFIX . $entity_type_id);

What do you think if we do the opposite using early-return?

Ex:

  foreach ($config_factory->loadMultiple($config_names) as $name => $config) {
    $entity_type_id = $config_manager->getEntityTypeIdByName($name);
    if (!$entity_type_id) {
      continue;
    }

It'll reduce one level of indentation, you know?

amanshukla6158’s picture

Status: Needs work » Needs review
StatusFileSize
new8.85 KB
new1.33 KB

made changes as per #70

mstrelan’s picture

Status: Needs review » Needs work

#71 needs work for phpcs errors

akram khan’s picture

StatusFileSize
new11.13 KB
new3.31 KB

added updated patch fixed CCF #71

_pratik_’s picture

Status: Needs work » Needs review
StatusFileSize
new12.4 KB
new5.38 KB
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

#71 seems to be removing the code of the post_update hook

#73 seems to be adding additional changes from #71

#74 seems to be the same as #73 and adding additional changes

So patch #69 should be starting point but #70 needs to be addressed.

sourabhjain’s picture

Assigned: Unassigned » sourabhjain

Let me work on #75.

sourabhjain’s picture

Assigned: sourabhjain » Unassigned
Status: Needs work » Needs review
StatusFileSize
new9.74 KB
new2.3 KB

I have tried to fixed the issue mentioned in #75. Please review.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

#77 does seem to address #70.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 77: 2960643-77.patch, failed testing. View results

sahil.goyal’s picture

Status: Needs work » Reviewed & tested by the community
larowlan’s picture

Status: Reviewed & tested by the community » Needs work

No longer applies

tanuj.’s picture

StatusFileSize
new9.77 KB
new1.28 KB

as patch #77 does not applies

error: while searching for:
    return $update;
  });
}

error: patch failed: core/modules/system/system.post_update.php:93
error: core/modules/system/system.post_update.php: patch does not apply

adding a reroll for #77, please review.

tanuj.’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Reroll seems good

larowlan’s picture

Status: Reviewed & tested by the community » Needs work

I don't see any exploration of the ::getOriginal method highlighted in #60, we've just been re-rolling the previous patch without seeing if that means we don't even need the new arguments.

Can we explore that first please? If it works the patch will be dramatically simplified.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

ekes’s picture

Issue tags: -Novice