Installed 4..0.rcs to fix the ability to remove recurrences, and now getting this error on the status page

Mismatched entity and/or field definitions

The following changes were detected in the entity type and field definitions.

Content

The node.field_event_recur_date field needs to be updated.

Drupal 10.1.3
PHP 8.1

Issue fork smart_date-3386133

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

DaveWilliamson created an issue. See original summary.

dgwolf’s picture

Same here on D 10.1.4 with PHP 8.1. After upgrading from SmartDate 3.7.2 to 4.1.0-rc2 two of my standard SmartDate fields were reported as being in need of such updates. There were no recurring dates involved but a simple "node.field_when" on a testpage and a similar field "commerce_product_variation.field_zeiten" in a set of commerce products. Downgrading to 4.0.3 resolved the issue. - Regards, Andreas

sandipta’s picture

You can install devel entity update module and use drush entup command to fix the issue.

dgwolf’s picture

Thanks, but are you sure? I abstained because of the warning on the devel_entity_updates module's page:
"Do not use this to fix the Mismatched entity and/or field definitions error: again, this is not meant to fix production sites."
"If you encounter that error you should identify which module defines the problematic entity type or field definition and open a bug report or support request in its issue queue."
Seems there is a newish module though called entity_update but it may not have the function that is needed here.

mandclu’s picture

The big blocker for me has been getting any sense of what Drupal thinks are the mismatched entity definitions. I know we updated the storage to use bigint, but even on a site where I validated that the DB update ran as expected (I validated that the fields were BIGINT in the DB after) I see the warning.

IMHO it isn't particularly helpful to throw that warning without some feasible way for a maintainer to access the perceived differences. I tried to go into core with debugging tools but I went several levels deep and still didn't get any useful detail

mandclu’s picture

Having done some more investigation, I believe the issue is that the existing update hook updates the main field table but not the revisions table. Working on a fix.

mandclu’s picture

To clarify the last comment: by running the database updates, the actual storage in the database table for revisions is updated, but for some reason the stored schema definitions for the revisions table is not. So other than the warning on the status page there should be no functional implications, but still investigating a fix for the warning.

dgwolf’s picture

Sounds good, and thanks for the background information in #5.

troybthompson’s picture

If it's helpful, I'm also seeing it in Drupal 9.5.11 and Smart Date 4.0.3

mandclu’s picture

Issue tags: +DrupalCon Lille 2023
Related issues: +#3304395: Far-future dates cause WSOD, "Numeric value out of range"

I'm fairly certain that this issue was introduced via the changes in #3304395: Far-future dates cause WSOD, "Numeric value out of range". The update added there does update the database tables, but core rejects updating the schema for fields that contain data. The changes currently proposed in #2885413: Timestamp field items are affected by 2038 bug do introduce a way to get the schema updated, so I will see if I can help that issue along, in addition to investigating a Smart Date-only fix.

avpaderno’s picture

Issue tags: -DrupalCon Lille 2023 +DrupalCon Lille 2023
mandclu’s picture

After some investigation into this, the only feasible path forward I've been able to find is by leveraging the optional "column_changes_handled" parameter that would allow for stored schema updates on fields that have data, as proposed in #2885413: Timestamp field items are affected by 2038 bug. Marking that issue as related, and will see what I can do to help that one along.

mandclu’s picture

Status: Active » Needs review

Moving this to Needs Review because in my testing the changes in the merge request successfully resolve the reported error in the Status report, although to do so the site needs to apply the changes from #2885413: Timestamp field items are affected by 2038 bug, at least the changes to SqlContentEntityStorageSchema.php that introduce handling of the column_changes_handled setting.

Within the comments on #2885413: Timestamp field items are affected by 2038 bug I did also propose adding the column_changes_handled setting in a separate issue that might be merged more quickly. I did have some challenges getting the changes from that issue's MR merged onto my install of Drupal 10.1.6, so having the smaller set of changes needed here in their own MR would also make getting them applied easier.

mandclu’s picture

I have also created #3406172: Provide a flag to allow updates to stored schema for fields as a more narrowly scoped way to introduce the change in #2885413: Timestamp field items are affected by 2038 bug on which the solution in this issue's MR relies. If you have trouble getting the changes in the latter issue to apply cleanly, you should be able to apply the changes in the new issue instead.

mandclu’s picture

Title: node.field_event_recur_date field needs to be updated » node.field_[name] field needs to be updated
Component: Smart Date Recur » Code
willids’s picture

can someone put the link here to the fix for this as all I am getting is the git drupal code and unable to do anything with that

mandclu’s picture

@Willids if you need a patch file you can download one at https://git.drupalcode.org/project/smart_date/-/merge_requests/70.patch

Just remember that before running the new db update provided by this issue's patch, you need to apply the patch from one of the core issues cited above, for example by grabbing a patch at https://git.drupalcode.org/project/drupal/-/merge_requests/5684.patch

froboy’s picture

I tested this with the "smart_date" module enabled but only using core fields and I received the following warning:

> [notice] Update started: smart_date_post_update_increase_column_storage
> [warning] Undefined array key 0 smart_date.post_update.php:81

It looks like the update could use a check for the case where there are no smart_date fields.

ronraney’s picture

I believe my problem is related. I had issues with this module after I updated to PHP 8.2. The solution I found was to install the ^4.1 version of the module, which appears to have addressed a PHP deprecation issue.

Since I updated the module, there were two site errors related to the module update. It required a database update. I ran the update. Then I ran drush entup because it said I needed entity updates. I am getting this message in Terminal:

In SqlContentEntityStorageSchema.php line 1750:

The SQL storage cannot change the schema for an existing field (field_smart_date in node entity) with data.

I'm not sure what needs to be done in my case. Do I use a specific patch shown above?

adrianm6254’s picture

Merge request !86 did not work for me. I tried Merge request !70 and found that worked for me in conjunction with patch at https://git.drupalcode.org/project/drupal/-/merge_requests/5684.patch as suggested in step #18

mandclu’s picture

Apologies, Merge request !86 is a work in progress, and not ready for testing yet. I'm trying a different approach that wouldn't require a core patch.

bramvandenbulcke’s picture

Will this be fixed in the 4.1.x version eventually? I'm working on a new, to launch project with this error. I could uninstall this version and install the 4.0.x version but that will take some work. If there is a fix in the future for this error, I could leave the error and wait for the fix. Everything is functionally working.

mandclu’s picture

@bramvandenbulcke The goal is definitely to get this fixed in the 4.1.x branch, in fact getting this issue resolved is the single biggest thing holding the 4.1.x branch back from a stable release.

As mentioned above, installing the linked patch to core and the changes in MR!70 should resolve the warning being displayed. Once the error is gone you should be able to uninstall the core patch as it will no longer be needed for this issue.

That said, there's no way to know when the core issue could be merged much less released, so I opened MR!86 as a potential alternate approach that wouldn't require a core patch, but it still needs some work.

mandclu’s picture

As an update, #3406172: Provide a flag to allow updates to stored schema for fields has now been merged into core and will be included in Drupal 10.3 and 11. As such, it should be safe to rely on a patch from that issue, and the update in Merge Request !70 to resolve the schema warning. It's also worth noting that once the update has been run and the schema warning dealt with, it should be safe to remove the core patch, if desired.

That said, I still plan to continue the work in Merge Request !86 to see if it's possible to resolve the schema warning without requiring any core changes.

bramvandenbulcke’s picture

Thanks for the update. I will wait for the fixes.

maxilein’s picture

D10.2.4 Read the thread, but just wanted to add some info. Maybe it is useful.

Just upgraded from Smartdate 4.0 to 4.1 beta 5

$ drush entup
The following updates are pending:

node entity type :
The node.field_timex field needs to be updated.

Do you wish to run all pending updates? (yes/no) [yes]:
> y

In SqlContentEntityStorageSchema.php line 1750:

The SQL storage cannot change the schema for an existing field (field_timex in node entity) with data.

coaston’s picture

Status: Needs review » Needs work

I just applied patch from Merge request 70 (3386133), but still the same issue as reported in #28.

mandclu’s picture

Did you apply the patch to core before running the updates?

coaston’s picture

Yes.
Update.php showed 1 or 2 pending updates and successfully updated. No issues.
However status report still shows the same and when i try to update field manually -re save the same issue.

mandclu’s picture

Status: Needs work » Needs review

Merge request !86 is ready for review. Please test that as an alternate fix that does not require any changes to Drupal core.

  • mandclu committed d850e48f on 4.1.x
    Issue #3386133 by mandclu: node.field_[name] field needs to be updated
    
mandclu’s picture

Status: Needs review » Fixed
bramvandenbulcke’s picture

I updated one site with this issue and after the db updates of 4.1.0-rc7 the errors are no more showing.

ronraney’s picture

How do I add this merge request? Can someone point me to instructions? I'm used to using patches. I updated the module just now, but I'm still getting this error when I run drush entup.

In SqlContentEntityStorageSchema.php line 1750:

The SQL storage cannot change the schema for an existing field (field_smart_date in node entity) with data.

I just tried to apply patch #70. https://git.drupalcode.org/project/drupal/-/merge_requests/5684.patch
I'm getting an error (with the newest version of the module). Composer says it cannot apply the patch but doesn't appear to offer any reason why it can't apply the patch.

ronraney’s picture

Update: In my case, I needed to do the database updates first, then the entity updates. When I did the correct order of commands, it all works out and I no longer need a patch. I'm not getting errors now after the updates.

Status: Fixed » Closed (fixed)

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