Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Follow-up of #2891215: Add a way to track whether a revision was default when originally created.
This is critical because it completely breaks entity types that still rely on the BC layer. Hopefully trivial to fix so we don't have to revert the other issue.
interdiff is big, easier to just read the new patch.
Comment | File | Size | Author |
---|---|---|---|
#91 | entity-rmk_update_fix-2936511-90.patch | 20.21 KB | plach |
Comments
Comment #2
BerdirNot quite as easy as I thought, tricky business with the BC layer and recursion, have to keep it in the constructor but change the BC logic to check for only one metadata key instead of none and also change EntityFieldManager to explicitly opt out of the BC layer.
Comment #4
BerdirMore fun, apparently the key isn't set during the upgrade path and there the BC still worked. So the BC needs to work if we have 0 or 1 revision metadata key.
Comment #5
timmillwoodBecause #2891215: Add a way to track whether a revision was default when originally created passed all core tests it feels as though we don't have suitable test coverage for this issue. To prevent future regression of this issue I think we should add a new test, and a test-only patch in this issue.
Comment #6
BerdirI thought about that, not sure. The easiest way to do that would be to have at least one (test or non-test) entity type that relies on the BC layer on purpose. Then that would break. But that will also trigger BC warnings.
Comment #7
plachBefore #2891215-57: Add a way to track whether a revision was default when originally created I was adopting a similar approach to what this patch is doing (counting keys), however @gabesullice (IMO) correctly pointed out that that's not a particularly solid approach. Can't we just explicitly check the keys?
I was about to suggest exactly that: why are BC warnings a problem? Are you concerned about keeping "deprecated" code around?
Comment #8
BerdirI guess we could explicitly check the keys, yes. I kinda dislike long multi-line if statements though :)
Well, one thing with triggering BC messages is that it will actually make the tests fail unless we specifically put them in \Drupal\Tests\Listeners\DeprecationListenerTrait::getSkippedDeprecations().. but turns out that we already have them there. I guess that's because we're still getting into that case during the upgrade path, which is also why my first patch failed.
Thoughts on where we want to remove them? a test or a non-test entity type? My vote would be for one in entity_test_revlog, simply becausae only a few tests would trigger it then, dozens of tests are enabled entity_test.
Comment #9
plachMe too :)
A separate boolean variable to be checked in the if test would work for me.
Yep, that's why I was confused by #6.
+1 on
entity_test_revlog
or a new dedicated entity test type.Comment #10
BerdirOk, removed the keys from one entity type there, confirmed that MoveRevisionMetadataFieldsUpdateTest now fails. Interestingly. RevisionableContentEntityBaseTest does not fail, it just happily creates the fields in the wrong table then and is consistently inconsistent and nothing explicitly fails. We could also add explicit coverage for the keys there, but I think this is enough?
About the keys, what if we add an if () for each of the 3 keys? Means a bit more nesting, but but then there are no strange special cases anymore and if someone manages to define only one of those keys then BC would still work for them.
Comment #11
plachDo you mean without the fix?
I think we were trying not to do this to avoid retrieving base fields. Not sure how much it buys, though.
Is this still needed?
Comment #12
BerdirUpdated the method as we discussed.
Comment #13
plachLooks good, assuming testbots agree!
Comment #16
hchonovWith this condition we'll execute the BC logic on each method call for the case where an entity type doesn't have any of those fields. If we want to prevent this we would have to use another property e.g.
$this->needsBC = TRUE;
to store the information whether the BC logic has been already executed.$needs_bc = $this->needsBC && !isset($this->revision_metadata_keys['revision_user']) && !isset($this->revision_metadata_keys['revision_timestamp']) && !isset($this->revision_metadata_keys['revision_log_message']);
and in the if statement we set that property to
FALSE
.Comment #17
BerdirGood point, but I think we already called it repeatedly if an entity type had none of those fields. With this change, the difference is that we'd also still call it if the entity type does not have all three but e.g. only the revision user and a log message but no timestamp.
At the same time, the previous code would never have called been called if only the revision_user key would have been defined? We can get the same behavior with isset() || isset() || isset(), further improvements could then be a separate issue and does not need to be in a critical regression fix? A bit worried about side effects of introducing more properties in those objects as they are persisted in entity definition manager and so on.
Comment #18
hchonovYes, but if a developer has defined one the keys, then it is her/his responsibility of providing all the keys. We've added the BC layer only because we cannot force the developers to set the revision metadata keys in the entity annotation until D9. Therefore it is fine to skip running the BC logic if one of the keys has been defined in the entity annotation, because this means the developer is aware of those keys.
Actually it is even wrong to run the BC logic if at least one the revision metadata keys has been defined, because the intention might have been to not consider the other fields as revision metadata keys and skip all the internal storage logic that we already have for them. Changing this might really break sites, as the storage will suddenly return completely different structure. I am sorry, but we have to restore the previous behavior - putting back the status to "needs work" for this.
We are constantly introducing new properties on classes, the objects of which are persisted. I don't see any problems with doing this. But beside that I think that we persist only the definition i.e. the annotation of an entity, not the entity type object itself.
Comment #19
hchonovI think the easiest solution will be to not define the revision_default key in the constructor, but retrieve it through the BC layer like we are retrieving the other revision metadata keys.
Comment #20
BerdirYes, @plach and I basically agree with this, but we changed the logic to explicitly check those 3 keys and not any others. If we ever add more than that then we'll have to adjust this logic but I think it's highly unlikely that an entity type sets other revision metadata keys but not those three, which happen to be basically default fields now with the recommended base classes.
We are persisting the entity type definition objects, for example through \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface::setLastInstalledDefinition() and related methods and not just as a cache but pretty much forever. And it's important that those do not get updated/extend automatically. So we definitely need to be careful with what we put in there.
This is not possible as far as I see for a combination of reasons, it has be be more or less exactly as it is now:
A) The revision_default key/field is added in system_update_8501(). It must not exist before that in the last installed definition. And having it in constructor enables that, because the constructor is not re-run on existing serialized objects.
B) The new key isn't a temporary BC fallback, it's a default, required key. Like default_langcode and revision_translation_affected, which are already defined in the parent in the same way. (not sure why those are there, though..) That means it would be outside of the BC logic but always be set. But the problem with that is that we would lock ourself out of the BC logic if we'd keep it. One of the first calls will be the one that calls it without BC in buildBaseFieldDefinitions(), then we would skip BC and initialize the key. But later on when we want BC, the array is no longer empty.
I actually tried to do what you suggested at first, but it doesn't work. IMHO, this is as close to the previous situation as we can get with the new default_revision flag. What I did is change the logic and variable name a bit to make it clearer when we are doing BC. Because I was actually confused about my own code before :)
Comment #21
plachComment #22
hchonovThat it is "unlikely" from our POV doesn't mean that it is unlikely from the POV of others. I think that it is not good, that we make decisions, because according to our opinion something is unlikely or really a rare use case. If we could solve it without having to break the BC then we should solve it like this, which means that we should handle the "revision_default" revision metadata key just like the other ones. The places where it is required have to check if it exist and if not hard code its name - until the update has been performed - and in the BC layer we just check if the field is provided in the base field definitions with the default name we use.
This might not be a beautiful solution, but it is how we currently deal with the other revision metadata keys and I think this is the only option we have until D9, where we'll require that the revision metadata keys are defined in the entity type annotation.
In the patch I am posting I've implemented it with the BC layer to show exactly what I mean and it is possible :).
If we don't want that the places needing the field name have to hard code it themselves then we could introduce a new method name
ContentEntityTypeInterface::getRevisionMetadataDefaultKeyName()
, which will simply return the default field name.Comment #23
BerdirBut revision_default should not be BC, we don't want every entity type to explicitly specify it, it is a requirement and is defined by default, just like default_langcode, which is also set by default in the keys. @plach explicitly said yesterday that he doesn't want that every entity type needs to specify it and I agree.
Comment #24
hchonovIn the patch that I've provided it is not specified by any entity type, but added automatically.
Comment #25
BerdirYes but it is inside the BC logic that will be removed and you trigger a warning if it's not set.
Comment #26
hchonovWhat is the problem with it being inside the BC logic? We can remove the error, it is actually not needed as it is us who add the metadata key.
Comment #27
amateescu CreditAttribution: amateescu for Pfizer, Inc. commented@hchonov, @Berdir explained why it shouldn't be inside the BC logic in #23 and I agree with that comment.
Comment #28
hchonovIt is not only in the BC logic but also in the constructor to cover the two cases where the revision metadata keys are provided / not provided in the entity type annotation. When the BC logic is removed then we'll just define it in the constructor without the condition that we currently have.
Sorry but I still don't understand what exactly is the problem with such an approach?
Comment #29
hchonovIs the warning that is causing the confusion? I am sorry about this, my bad for adding it. I've removed the warning. This patch doesn't force any entity type to define the "revision_default" key and when we remove the BC layer the key will be just defined in the constructor like now, but we will simply remove the condition that we currently have in the constructor.
The file "content_entity_type_d9.txt" shows how the entity type will look like in D9.
Comment #30
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThis is the problem with this approach. The system should *always* have a
revision_default
metadata key defined, either by default or specified in the entity annotation.Comment #32
hchonovLike mentioned in Slack it is not possible because of the BC layer we've provided which relies on the revision_metadata_keys property being empty.
Here is the another approach where we need to make the BC layer a bit more complex but this way the "revision_default" key should always be returned by new instances of the class and never returned by unserialized objects prior to the update to cover the case where the entity type objects are cached in the
EntityLastInstalledSchemaRepository
.@berdir will probably not be happy with this approach as he stated in #17:
Comment #33
BerdirDoesn't your own argument work against you here?
If I explicitly add revision_metadata_keys = ['revision_default' => 'revision_default'] to my entity type, then it will still call the BC logic.
I'm fine with that. But you argued that it shouldn't do that anymore as soon as any key is set explicitly by the user.
I'm OK with this patch, but you kind of aren't :)
To summarize, I'm fine with doing any of the following:
* this patch
* this idea with just hardcoding revision_default directly in the BC logic, I don't care that much about duplicating and hardcoding it, I don't think we'll add another 5 required keys and we can live with 1-2 additional hardcoded ones.
* my last patch
* your previous one
@plach also suggested adding a helper method that would prevent us from duplicating the revision_default fallback in EntityFieldManager. After thinking about it, I don't really like adding a public method to the class/interface because of a temporary BC layer that most likely nobody else will have to worry about.
Comment #34
plachFWIW this is what @Berdir was referring to in the last paragraph of the previous comment:
https://gist.github.com/plach79/dda896dad256d507939ebd31e1558b0a
Comment #35
plachSpent some more time discussing this with Berdir in Slack. I suggested an adjusted version of #33 (see https://gist.github.com/plach79/f22ceca27c8d071464f46e46d5769f24) while he suggested a simplified version that cannot be fixed the way I was suggesting (see https://gist.github.com/Berdir/410dc15cc4ff06aa2675503c7d500fa6).
I'm personally fine with both, but if we need to support these edge cases properly, we also need some test coverage, otherwise we will keep breaking stuff. I think that having a new test entity type defining only the
revision_default
key + some assertions around the generated schema should be enough.Comment #36
BerdirHere is a patch for that gist to do what I described above as the second item. I'm OK with #33 too but I think the property for that is overkill for the single required property that we have no, we can always go back to that if we end up with different ones.
@plach will also post a gist or so for an approach that would fix the scenario that I described in #33 but I personally don't think it needs to be fixed. To clarify that, he only case that would be weird now is if that entity type would define only revision_default *and* would have a revision_user/.. field and would *not* want that field to be used as a revision metadata field. And the workaround for that would be to put a dummy key in the annotation so it's not empty/equals the required values. But such a workaround would already be required right now in 8.4.
Setting to needs review to have this tested too. To have a test for #35, we first need to agree on what should happen in that case, whether or not that should run BC. If running BC is fine, then we just need to change the keys accordingly on the second test entity type and our existing asserts in the update tests should be sufficient? If not then we'll need likely a new module with a new entity type.
Comment #37
hchonovGood catch... I had another solution which I tried to simplify and didn't notice that I've introduced that behavior for this key. But the fix for this is pretty simple - we should not add the key to the new property if it is already provided in the annotation :). This way the condition
($this->revision_metadata_keys === $this->requiredRevisionMetadataKeys)
will evaluate toFALSE
because the property$this->revision_metadata_keys
will not be empty and will not equal the empty property$this->requiredRevisionMetadataKeys
.The property has an idea and it is to always store the state of the last version which covers cached entity type objects. If we remove the property the next time we introduce a new key the condition in the getter method will have to be defined like this:
where
($this->revision_metadata_keys === $previous_required_revision_metadata_keys)
will match entity type objects that have been cached and($this->revision_metadata_keys === $new_required_revision_metadata_keys)
will match new instances.To prevent such complex updates and additions to the required revision metadata keys we have to keep the property.
Comment #38
hchonovShould we merge the changes from this issue into the parent one, which has been reverted?
Comment #39
BerdirIt was only reverted from 8.5.x so that it's not in the alpha. AFAIK it will be committed again as-is once that is released. I'd agree but we would need to revert in both versions first.
Comment #40
plachLet's keep things simple and keep working here, please :)
Did we reach consensus on how to move forward? It seems to me that #37 is an alternative to fix #32 that is similar in principle to what I was suggesting.
@hchonov:
Can we try that and add test coverage for the use cases it support?
Comment #41
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedIsn't this enough to fix the BC layer?
Comment #42
hchonov@plach, I'll write a test later today.
@amateescu, unfortunately this is not enough, because we don't want to execute the BC layer if the entity type definition ships with already set revision metadata keys.
@see #18:
Comment #44
effulgentsia CreditAttribution: effulgentsia at Acquia commentedJust confirming that this is correct. This issue's "version" field is set to 8.6.x and so can proceed, since #2891215: Add a way to track whether a revision was default when originally created is already in 8.6, and so the patch in this issue can be committed to 8.6 regardless of when 8.5 alpha is tagged. Once 8.5 alpha is tagged, I'll cherry pick that issue back into 8.5, as well as this one when it's ready.
Comment #45
hchonovAnd here is the test and the fix so that we are able always to detect if the revision metadata fields have been defined in the annotation or not.
Comment #46
hchonovComment #48
plachI'll have a look ASAP, thanks!
Comment #49
plachThis looks great to me, thanks a lot for the expanded test coverage!
I have only a few minor nits:
Superminor: can we add a comma before "therefore" in both cases? :)
These are a bit confusing at first sight: do we need them given that the objects are type-hinted below?
Can we also add an assertion for the expected behavior with the BC-layer enabled?
Btw, why are we base64-encoding the cached item? Wouldn't it be easier to troubleshoot this code in the future, if we just had the serialized string?
Comment #50
Wim Leers#49:
I don't know this well enough to be sure what you're asking here. Can you clarify?
I tried, but we can't get rid of this AFAICT:
fails with:
and
fails with:
Comment #51
Wim Leers#50's interdiff was wrong, and the filename even indicated that.
Comment #52
effulgentsia CreditAttribution: effulgentsia at Acquia commentedThank you for everyone's diligent work on this. Just a reminder that 8.5 beta is next week, which will be the first tagged release since #2891215: Add a way to track whether a revision was default when originally created landed. Any help with final reviews and testing would be very much appreciated, so that ideally beta testers updating existing (alpha1 or earlier) sites can do so without getting those databases into a broken state. Thanks!
Comment #53
effulgentsia CreditAttribution: effulgentsia at Acquia commentedComment #54
effulgentsia CreditAttribution: effulgentsia at Acquia commentedFYI: #2941733: block_content_revision loses columns due to incorrect entity definition was recently opened with additional information relevant to this.
Comment #55
mpdonadioIs this the same problem?
Comment #57
plach@Wim Leers, #50:
I meant that we should add an invocation of
::getRevisionMetadataKeys(TRUE)
and verify that the returned value is correct.@mpdonadio, #56:
That test does not look right to me: it is not running updates. Loading an entity before updates have run may indeed lead to executing a broken query.
Comment #58
Wim Leers#57: I see. But we can't do that for
\Drupal\Tests\system\Functional\Entity\Update\TestRevisionMetadataBcLayerEntityType
, since it's not an actual entity type and hence this:in
\Drupal\Core\Entity\ContentEntityType::getRevisionMetadataKeys()
will fail. How do you propose we do that then?Comment #59
plachOk, makes sense, let's ignore my suggestion. #50 seems ready to go to me, I will RTBC it tomorrow morning, unless @Berdir has any concern.
Comment #60
plachRTBC patch is #50.
Comment #61
hchonovSorry, I am currently working on an updated patch :). Will post it in a minute.
Comment #62
hchonovI am sorry for the delay.
Actually it is possible to add the test case where we check the BC layer of the serialized entity type. TestRevisionMetadataBcLayerEntityType is just the class, but the entity type it represents is defined through the "id" property. Therefore if the id represents a real entity type, then the entity field manager will be able to provide the base field definitions and so properly execute the BC layer.
When I've created that serialized entity type initially I used "test" for the id property, which doesn't represent any entity type. In the current patch I've exchanged it with the entity type "entity_test_mul_revlog", for which we've removed the revision metadata keys from the annotation so that we could test the BC layer.
@plach, now we have the additional test with the BC layer, that you wished :).
@plach, I had to use base64 encoding instead of simply providing the string output from
serialize()
, as I was unable of unserializing it. I've found the idea to use base64 encoding for such cases in https://stackoverflow.com/questions/10152904/unserialize-function-unseri... . Is there a better way of doing this?@berdir pointed me to a new issue regarding this subject, but I was unable of reproducing it - #2941733: block_content_revision loses columns due to incorrect entity definition and I am not sure if it should prevent the current one from getting in?
Comment #64
hchonovI've just noticed, that I've uploaded the interdiff as a patch ... I'll be back on my computer in 40 minutes and will upload the whole patch. I am sorry for this ...
Comment #65
plachThanks!
Well, unless it's directly causing that issue I think this shouldn't be blocked, I also tried to reproduce that issue without luck.
Comment #66
hchonovHere is the patch my comment #62 was about.
P.S. It looks like I should not upload any patches anymore today :). I have no idea how I've managed it to upload the patch and the interdiff twice.
Comment #67
hchonovAfter talking with @berdir about #2941733: block_content_revision loses columns due to incorrect entity definition, I've realized that with the new BC logic the update hook for adding the revision_default revision metadata key isn't complete. I've extended the patch and I am curious if somehow this is solving the referenced issue.
Comment #68
plachTests are green and I also manually tested the upgrade from 8.4 to 8.5 once again and it seems to be working fine.
I get a couple of "The entity type block_content does not have a "published" entity key." notices, but it's the same in HEAD, so I think this is ready to go now.
Comment #69
Berdir> I get a couple of "The entity type block_content does not have a "published" entity key."
I only got those when updating directly from 8.3 to 8.5, not 8.4. And they're not notices but exceptions. And then it worked the second time I executed drush updb.
I think that's related to the order in which block_content_8400() and other update functions are executed. We might need some explicit dependencies there if we depend on a certain order.
Comment #70
plachCreated #2942533: "The entity type block_content does not have a "published" entity key." notices when updating from 8.4 to 8.5 for the notices issue.
Comment #71
BerdirTo be clear, pretty sure that is *not* caused by that issue, I reproduced those errors without this patch while looking at #2941733: block_content_revision loses columns due to incorrect entity definition, it's just standard update function dependency fun (*hint* #2942096: [policy, no patch] Remove old update hooks prior to each major version (Drupal 10 and later) *hint*)
Comment #72
plachYep, I agree those seem to be unrelated.
Comment #73
sdewitt CreditAttribution: sdewitt commented#67 looks like it might resolve #2941733: block_content_revision loses columns due to incorrect entity definition with patch 2936511. Trying it now.
Comment #74
sdewitt CreditAttribution: sdewitt commented@berdir @hchonov @plach #67 resolves the loss of the columns reported on #2941733: block_content_revision loses columns due to incorrect entity definition with patch 2936511. I apologize I did not realize that it was really the same issue and keep all the history here in this patch discussion. Thanks for all your hard work on this one. Please feel free to close out 2941733 as a dup.
Comment #75
plachThanks for reporting, glad we were able to sort this out. It would be bad if we discovered it post commit ;)
Comment #76
hchonovYay, I am happy that #67 is resolving your issue, @sdewitt.
We should add a test for the interdiff in #67, which is resolving the referenced issue. We'll certainly need the same test the next time we add a new required revision metadata key.
Comment #77
plachGood point
Comment #78
hchonovAny thoughts on how we could reproduce the problem in a test?
Comment #79
plachNo idea, honestly, I was never able to reproduce that problem. We could try to break the logic we had in place before the latest iteration and see whether that helps reproducing the issue. Worst case we would get implicit test coverage.
Comment #80
mpdonadioRe #56 and #57, that wasn't a real test. It was just the minimum amount of code to show the problem (the query barfing). The test I was working on was an update test that
- use the filled fixture (drupal-8.filled.standard.php.gz)
- loaded one of the test nodes
- checked the field value
- ran updates (which does a field value change)
- reloaded the node
- checked the field value to see if the update worked.
The problem (for me at least) means that drupal-8.filled.standard.php.gz won't work (others may have this too, didn't check). I can make my own fixture; just wanted to use what was there. Rebuilding it may (or may not) be worthy of a followup.
Committers: please remove my credit on this; my file on this issue didn't add any value to the patch.
Comment #81
BerdirYou can't do this. Loading/using the entity API before/during updates is *not* supported. That's why we have post updates.
If you want to check the initial value, then do a raw DB query against the table.
Comment #82
effulgentsia CreditAttribution: effulgentsia at Acquia commentedAre we sure we want a strict (
===
) comparison here? Aren't there pathways by which they might not be in the same order? For example, if there ends up being a 2nd required one, added in a child class and therefore defined before'revision_default'
, but an update function adds it to the last installed definition after'revision_default'
was already added bysystem_update_8501()
?This line of code is doing more than the comment says, depending on what else happens to be in
$required_revision_metadata_keys
besides'revision_default'
. I think it would be best to limit the scope of this update function to only'revision_default'
, and leave future required keys to the update functions of the patches/modules that introduce them. Or is there a reason we need/want to merge in the entire required array here?This entire block only runs when there isn't already an installed field that happens to be named
'revision_default'
. But then we're in a situation where in such a case, the metadata keys end up being different between the last installed definition and the runtime code one. I think it would make more sense to run this block outside of theif (!$definition_update_manager->getFieldStorageDefinition($field_name, $entity_type_id)) {
statement that's above it, since nothing in here needs to distinguish between whether that field already exists or not.If I understand correctly (please correct me if I don't), the problem prior to #67 was that
system_update_8501()
ran in such a way that following it,$installed_entity_type->getRevisionMetadataKeys()
would not support the BC of'revision_user'
etc. And in #2941733: block_content_revision loses columns due to incorrect entity definition that manifested whenblock_content_update_8400()
ran aftersystem_update_8501()
. In which case, can we expandEntityUpdateAddRevisionDefaultTest::testAddingTheRevisionDefaultField()
to check that following the updates, that$installed_entity_type->get('requiredRevisionMetadataKeys')
and$installed_entity_type->get('revision_metadata_keys')
are what we expect and/or that$installed_entity_type->getRevisionMetadataKeys()
returns what we expect? I think that would be sufficient test coverage, or am I missing something?Comment #83
catchI found several issues with the comments. This patch doesn't address #82, but it addresses my comment nits (seemed easier to directly make the changes than post a review).
While I wouldn't block this patch going in on it, because we already have the data loss in HEAD, I think we should have actual upgrade path tests that expose this issue (i.e. with an entity type that requires this bc layer, with some content in the db for it).
Comment #84
BerdirWe do, with this change, the existing test we have for the upgrade path of this are failing. See test-fail in #10.
Comment #85
plachWhat about committing this as soon as #82 is addressed and trying to improve test coverage as a follow-up?
Comment #86
plachWorking on #82.
Comment #87
catch#84/#10 is what I asked for indeed, I just didn't realise it was already covered, so fine with any additional coverage we can add being a follow-up.
Comment #88
plach@effulgentsia, #82:
1: Seems a good fix to me. I manually checked the update once again and
requiredRevisionMetadataKeys
is initialized with an array even when the parent object is being unserialized, so I don't think we are at risk of matching a NULL with an empty array, which would be the only unintended scenario allowed by this change.2: Fixed
3: I think the current logic is correct, imagine the following scenario:
revision_default
field;system_update_8501()
runs while the codebase has not been updated to deal with the newrevision_default
revision metadata key, the latter will get a default value ofrevision_default
, thus matching the existing field;system_update_8501()
would do all the work and the provider module update would return early, but the end result would be correct also in this case.If instead we go the way you suggest, we will be missing the warning in step 4, which I don't think would be correct.
4: Yep, that's what I meant in #79. Implemented that. Attaching also a failing patch.
Comment #89
hchonov@effulgentsia, #82.3
If this happens then this is bad, really bad, as we rely on the field not being there. If an entity type already defines a field with such a name, we cannot simply reuse it and pretend it is the core field. How do we handle this? We cannot simply throw an exception, but probably log an error? I think we should start defining core reserved field names and not allow custom/contrib using them.
P.S. I've just seen the response of @plach about this in #88. Then I guess everything is correct.
P.S.2 @plach, but I think that it would be good to add an else branch and log an error pointing to the CR.
Comment #91
plachThis should address #89.
Comment #92
BerdirLooks good to me, I think all the reviews have been addressed.
Comment #93
effulgentsia CreditAttribution: effulgentsia at Acquia commentedLooks good to me as well. Thanks!
Removing credit from @mpdonadio per request in #80. Adding credit to @sdewitt for the testing in #2941733: block_content_revision loses columns due to incorrect entity definition that led to this patch's improvement.
Comment #96
effulgentsia CreditAttribution: effulgentsia at Acquia commentedThank you to everyone for helping resolve this critical regression prior to beta! Pushed to 8.6.x and 8.5.x!
Comment #97
KarimBou CreditAttribution: KarimBou commentedHi, I updated from 8.4.4 to 8.5.0beta and i'm getting this error, i checked the patch it is present, i've been struggling trying to find how to resolve this.
Comment #98
BerdirAre you sure that you did run all updates after doing the update?
That problem does not seem to be related to this issue.
Comment #99
hchonovHm even if the update hasn't been executed and the field isn't present then why would the storage assume it is there?
Comment #100
BerdirBecause we always look at the runtime definitions and *not* the last installed definitions for field definitions and entity types. There's an issue to change that, but not sure how easy that is.
Comment #101
KarimBou CreditAttribution: KarimBou commented@Berdir Yes I did check all the updates and even tried to restor databse to 8.4.4 and update again to 8.5.0beta.
I fixed this by adding a column "revision_default" in table 'media_revision'.
But now i'm getting this error after I followed upgrade path for Media which is now implemented in core. But I get this error when i try to add a Media. I tried recreating my own media type but i still get the same error:
Any idea if this might come from the previous error i mentioned above ?
Comment #102
catch@KarimBou could you open a new, critical, issue for this report?
Comment #103
BerdirThe second error sounds to me a bit like its related to media_entity/media and an unclean solution there. Are you sure that all the updates did run through and there was no error that is blocking the execution of other updates? drush updb should report no pending updates.
But yes, lets open a new issue and discuss there.
Comment #105
BlinX CreditAttribution: BlinX commentedReferring to my problem as described in
I am still trying to fix this.
At this moment I get these errors:
Since I see this is mentioned (solved!?) in this thread , can anyone tell me what to do (I am lost...) Thanks!
Comment #106
hchonov@BlinX, these errors occurred during the update, right? Did you update your site through
drush updb
or through the Drupal UI?Comment #107
BlinX CreditAttribution: BlinX commented@hchonov, I first attempted a few times by Drupal UI, then after reading severall related posts I learned to install/use Drush and tryed drush updb and drush entup also few times.
Although this happened last time:
Site is in D8.4.8, drush updb to D8.5.3 did not work.
So I used Installatron to upgrade to D8.5.3 and after that did drush updb and drush entup.
I saw a lot (good things I believe) happening in Drush, but also the Errors I mentioned before...