Problem/Motivation

Pathauto users currently are confused by entity field definition mismatch errors appearing on the status report.

That is because pathauto has to make path fields computed. The strange part about that is that getFieldStorageDefinitions() "eats" computed fields, so it's as if it vanished.

The thing is that already in core, that field uses custom storage (actually: no storage at all). So we go from custom storage to computed.

Proposed resolution

As quickly discussed with @plach, I'm proposing to ignore any change and deletion (possibly addition too?) of fields with custom storage [in status reports].

See also SqlContentEntityStorageSchema::requiresFieldStorageSchemaChanges(), which already ignores most changes of storage definitions that has custom storage. Which makes sense, as there's absolutely nothing that it could do anyway.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Berdir created an issue. See original summary.

berdir’s picture

Title: Ignore field definition changes from fields with custom storage » Ignore field definition removals/additions from fields with custom storage
Status: Active » Needs review
Issue tags: +Needs tests
Related issues: +#2661178: Error: Mismatched entity and/or field definitions
StatusFileSize
new1.63 KB

As shown by the referenced code, changes are actually already kind of covered, although we might want to go even further. So for now, just adding it for created/deleted. Lets see if there are any test fails.

Related pathauto issue: #2661178: Error: Mismatched entity and/or field definitions

banacan’s picture

Berdir,

Thanks for the info. I was worried about this until reading this thread and the related one you reference. So based on your comments I will simply ignore the error.

Thanks for all of your hard work on this critically important module.

dawehner’s picture

+++ b/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php
@@ -287,12 +287,21 @@ protected function getChangeList() {
+            // Ignore the deletion if the storage definition has custom storage.
...
+            // Ignore the deletion if the original storage definition had custom
+            // storage.

Would be nice to explain WHY we are doing things here.

lokapujya’s picture

Issue summary: View changes

Adding [in status reports], because the first 2 times I read this I didn't get it.

berdir’s picture

I'm not sure about that addition, we don't just ignore it there. We ignore it everywhere.

lokapujya’s picture

Ok, but I think this is about "ignoring the reporting of changes" to fields, for some reason when I first read it I thought that it was "blocking the changes".

plach’s picture

Status: Needs review » Needs work

The patch looks good to me, I guess we are only missing test coverage.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

fomenkoandrey’s picture

After update to Drupal 8.1 the same error present.
Will the decision of this problem?
I still do not install the module, waiting for solution of the problem for many months.
but it is very necessary in the work site.

alexpott’s picture

So I've worked on the pathauto side of this today #2661178: Error: Mismatched entity and/or field definitions and whilst it is possible to do something about pathauto using install and uninstall hooks I think the solution here is way better.

alexpott’s picture

Priority: Normal » Major
Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new2.01 KB
new3.64 KB

Here's a test. Given the number of reports and what people are doing to get around it I think this is a major bug.

alexpott’s picture

I think we might need a update function to remove the field definitions which have custom storage from the schema repository.

berdir’s picture

Test looks good to me.

Not sure if we need that update function. Don't we also have to prevent then that they are written in the first place? Or is that already the case now?

Also, Berdir-- for being too lazy to write a test myself :)

The last submitted patch, 12: 2673628-12.test-only.patch, failed testing.

alexpott’s picture

I think they are written - hence the error in pathauto about having to delete the fields... I'll work on this.

alexpott’s picture

StatusFileSize
new4.73 KB
new7.33 KB
new8.26 KB

Here's tests for what happens when you install a new entity type with a custom storage field and an upgrade path.

berdir’s picture

I'm not convinced that we need that:

a) It will prevent us from using the last installed definitions as the runtime API, ever.
b) It will also make the existing code pretty useless, because that scenario would then never happen?

Let's wait and see what @plach thinks.

The last submitted patch, 17: 2673628-17.test-only.patch, failed testing.

alexpott’s picture

@Berdir you still need the changes otherwise it'd always show up in the report page. But if you can change a definition without having to update the definitions to say that this is the definition that is now applying what is the point?

plach’s picture

Sorry, lost track of this, will review it ASAP.

xjm’s picture

Issue summary: View changes

Adding the screenshot from #2661178: Error: Mismatched entity and/or field definitions to clarify what this bug is about. The message is displayed to site administrators.

My understanding is that users see this message under normal site operation with any field with custom storage (including those used by Pathauto) and there is no way to work around it in contrib, correct? However, it does not actually impact the functionality other than displaying a confusing error to admins and adding a little crufty stuff to stored configuration.

berdir’s picture

Correct.

Users get this when installing pathauto. Because pathauto makes the path field computed, which is using custom storage in core (read: no storage). So right now, they get an error to go from custom/no storage to computed + custom/no storage, which is a no-op. but we show the error and force users to run e.g. a drush command, which then decides to do nothing :)

xjm’s picture

Issue tags: +D8 major triage deferred

Thanks @Berdir.

The developers discussed this with the Entity and Field maintainers and decided to defer triage on it. While the bug is only an admin-facing error message, it is confusing a lot of people and causing a lot of duplicate bug reports, plus also leading people to some really strange/ill-advised workarounds. It's possible that #2539634: PathItem::delete() never runs because the path field type is a computed field in disguise might make this issue less problematic for pathauto, so if that is fixed, we can revisit this and consider downgrading to normal.

(Edit: wrong issue link)

fomenkoandrey’s picture

I find it hard to understand the discussion of development in English.
so the question.
if I install the module now, whether the difficulty to correct this error in the future?
or an error will be eliminated by simply updating the module / core Drupal?
or should wait a little longer, if in the near future will fix this error?
(I do not use drush, but many of errors corrected using it).
thanks for the answer.

berdir’s picture

It's safe to use pathauto (I assume that's what you are asking) now, there is no real error. It will go away once this and/or #2539634: PathItem::delete() never runs because the path field type is a computed field in disguise is fixed.

kristiaanvandeneynde’s picture

Isn't the bug in #2539634: PathItem::delete() never runs because the path field type is a computed field in disguise a manifestation of the issue reported here? Changing the path field from hasCustomStorage() to isComputed() won't change the underlying issue of custom storage/computed fields incorrectly showing up on the status report.

As mentioned in #24, people with knowledge of this issue will know to ignore it or to run drush entup, but people who don't know this will start Googling and god knows what they may end up doing in order to "fix" this.

I'd like to think of this issue as unrelated to #2539634: PathItem::delete() never runs because the path field type is a computed field in disguise and see it fixed in core. The other issue is about the way path.module implements its FieldItem and FieldItemList classes.

That being said, the patch in #17 looks great, with these tiny nitpicks:

  1. +++ b/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php
    @@ -281,12 +281,21 @@ protected function getChangeList() {
    +            // Ignore the deletion if the storage definition has custom storage.
    

    Should say creation?

  2. +++ b/core/lib/Drupal/Core/Entity/EntityLastInstalledSchemaRepository.php
    @@ -66,6 +66,10 @@ public function getLastInstalledFieldStorageDefinitions($entity_type_id) {
    +    // Field storages with custom storage are ignored.
    

    Should say field definitions?

berdir’s picture

This is definitely a separate issue.

But 99% of the people see this currently specifically because of the path field, and if we make that already computed in core then pathauto does not have to dynamically change it anymore and the error goes away because nothing is changed.

This will not fix this issue, but it will become a rare special case instead of happening for everyone using pathauto.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

plach’s picture

I just had a look to this again. Both #18 and #20 make sense to me, I'm wondering whether it would make sense to always keep custom storage definitions in the last installed repository but silently applying changes when they are detected in the proper contexts, e.g. when update.php is run.

+++ b/core/modules/system/src/Tests/Update/CustomStorageEntityDefinitionUpdateTest.php
@@ -0,0 +1,35 @@
+  public function testAllowedHtmlUpdate() {

Huh?

kristiaanvandeneynde’s picture

It's been a while since I had a look at this issue. Is there something specific that needs to be done for this to move forward again?

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.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.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.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.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.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.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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.

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

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.

xjm’s picture

Issue tags: -D8 major triage deferred

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

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: +Needs Review Queue Initiative, +Needs issue summary update

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

Wondering if this is still an issue? Using pathauto with Drupal 10.1.x on a standard install I don't see any errors.
Tagging for issue summary update for steps to reproduce/updated screenshots.

Version: 9.5.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. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)
Issue tags: +Bug Smash Initiative

There has been no follow up to the prompt 2 years ago for more information. Therefor, I am closing this is as outdated.

If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").

Thanks!