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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jastraat created an issue. See original summary.

ChrisSnyder’s picture

When/where are you seeing this error? When running drush updb or when clearing caches?

jastraat’s picture

In the status report:

There were no update hooks added between version 8.x-1.5 and 8.x-1.6.

ChrisSnyder’s picture

Thanks 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.

jastraat’s picture

I'm afraid this isn't really my area of expertise. I doubt we're the only ones seeing this error though.

ChrisSnyder’s picture

I can confirm that I am seeing it on my sites that I updated too. So you are not the only one.

I'mBatman’s picture

1. 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:

 *   revision_metadata_keys = {
 *     "revision_user" = "revision_user",
 *     "revision_created" = "revision_created",
 *     "revision_log_message" = "revision_log_message",
 *   }

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.

I'mBatman’s picture

Adding the patch implementation for this issue, tested on 8.9.13 & 9.1.4.

ChrisSnyder’s picture

Status: Active » Needs review

Thank you Batman! Will review.

danthorne’s picture

Also have this error

ChrisSnyder’s picture

Batman, 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.

achap’s picture

Just 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

  • I'mBatman authored 1fe0314 on 2.x
    Issue #3194076 by I'mBatman, jastraat, chrissnyder, danthorne, achap:...
ChrisSnyder’s picture

Status: Needs review » Fixed
ChrisSnyder’s picture

Title: Mismatched entity and/or field definitions after update to 8.x-1.6 » Mismatched entity and/or field definitions after update to 8.x-1.6 / 2.0
Version: 8.x-1.x-dev » 2.x-dev

Status: Fixed » Closed (fixed)

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