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
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | 2673628-17.patch | 8.26 KB | alexpott |
| #17 | 12-17-interdiff.txt | 7.33 KB | alexpott |
| #17 | 2673628-17.test-only.patch | 4.73 KB | alexpott |
| #12 | 2673628-12.patch | 3.64 KB | alexpott |
| #12 | 2673628-12.test-only.patch | 2.01 KB | alexpott |
Comments
Comment #2
berdirAs 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
Comment #3
banacan commentedBerdir,
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.
Comment #4
dawehnerWould be nice to explain WHY we are doing things here.
Comment #5
lokapujyaAdding [in status reports], because the first 2 times I read this I didn't get it.
Comment #6
berdirI'm not sure about that addition, we don't just ignore it there. We ignore it everywhere.
Comment #7
lokapujyaOk, 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".
Comment #8
plachThe patch looks good to me, I guess we are only missing test coverage.
Comment #10
fomenkoandrey commentedAfter 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.
Comment #11
alexpottSo 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.
Comment #12
alexpottHere's a test. Given the number of reports and what people are doing to get around it I think this is a major bug.
Comment #13
alexpottI think we might need a update function to remove the field definitions which have custom storage from the schema repository.
Comment #14
berdirTest 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 :)
Comment #16
alexpottI think they are written - hence the error in pathauto about having to delete the fields... I'll work on this.
Comment #17
alexpottHere's tests for what happens when you install a new entity type with a custom storage field and an upgrade path.
Comment #18
berdirI'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.
Comment #20
alexpott@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?
Comment #21
plachSorry, lost track of this, will review it ASAP.
Comment #22
xjmAdding 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.
Comment #23
berdirCorrect.
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 :)
Comment #24
xjmThanks @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)
Comment #25
fomenkoandrey commentedI 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.
Comment #26
berdirIt'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.
Comment #27
kristiaanvandeneyndeIsn'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:
Should say creation?
Should say field definitions?
Comment #28
berdirThis 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.
Comment #30
plachI 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.
Huh?
Comment #31
plachComment #32
kristiaanvandeneyndeIt'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?
Comment #42
xjmComment #44
smustgrave commentedThis 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.
Comment #46
quietone commentedThere 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!