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.
Problem/Motivation
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Sitewide Alert
The Revision log message field needs to be installed.
The Revision log message field needs to be uninstalled.
Steps to reproduce
Upgrade a site from 8.x-1.5 to the latest version 8.x-1.6
Proposed resolution
Given the error, I think the conclusion that no update hook was required in #3160908: [D9] Missing revision metadata key in sitewide_alert entity impacting installation may have been incorrect.
Comment | File | Size | Author |
---|---|---|---|
#8 | fixing_mismatched_field_definitions-3194076-7.patch | 7.27 KB | I'mBatman |
#3 | Status_report___The_Journey.png | 25.06 KB | jastraat |
Comments
Comment #2
ChrisSnyderWhen/where are you seeing this error? When running drush updb or when clearing caches?
Comment #3
jastraat CreditAttribution: jastraat at Technivant commentedIn the status report:
There were no update hooks added between version 8.x-1.5 and 8.x-1.6.
Comment #4
ChrisSnyderThanks for the screenshot and clarifying!
I am open to any suggestions and/or patches to fix this issue.
To be honest, I am a little stumped. Based on the message in the screenshot, the Revision log message field both needs to be installed AND uninstalled??? Seems like a Schrödinger's cat problem.
Comment #5
jastraat CreditAttribution: jastraat at Technivant commentedI'm afraid this isn't really my area of expertise. I doubt we're the only ones seeing this error though.
Comment #6
ChrisSnyderI can confirm that I am seeing it on my sites that I updated too. So you are not the only one.
Comment #7
I'mBatman1. Where the issue is coming from?
The issue was introduced in this commit: https://git.drupalcode.org/project/sitewide_alert/-/commit/02e977c516f61...
2. What is the cause of the issue?
The column "revision_log_message" was renamed accidentally to "revision_log" in the table "sitewide_alert_revision" and Drupal detected it as a field definition mismatch and is just trying to drop the old column "revision_log_message" and add the new one("revision_log").
3. How to fix the problem:
We need to rename the column "revision_log" again to its old name:
and since there may be sites with the new version of the module installed with the wrong name(revision_log) we need to write an hook_update_N to rename the column using Schema::changeField().
Thanks.
Comment #8
I'mBatmanAdding the patch implementation for this issue, tested on 8.9.13 & 9.1.4.
Comment #9
ChrisSnyderThank you Batman! Will review.
Comment #10
danthorneAlso have this error
Comment #11
ChrisSnyderBatman, I have reviewed your patch and it looks like a sane approach. I really wish that Drupal had an easier way to rename a column, wow there is a lot you have to do.
Before applying your patch and creating a release, because this fix requires DB changes, I would like to get a few more people to review and test. I want to avoid having to run into this issue again where different sites are using different schema depending on which version they are on and if they directly installed that version or upgraded to it.
More reviewers are welcome.
Comment #12
achapJust chiming in and saying that the patch from #8 is working for me on Drupal 9.1.4. I noticed this error after upgrading. It works for me in the sense that the error goes away in Status Report. I can also create Sitewide alerts fine. However, when testing revisions I noticed that new revisions are never created. This is not related to this patch though. See the linked issue for a fix:
#3200873 New revisions are never created.
Only thing from the patch I noticed was a spelling mistake:
sitewide_alert_raname_metadata_key
Comment #14
ChrisSnyderComment #15
ChrisSnyder