Updated as of comment #20
Problem/Motivation
In #2921810: Allow TimestampFormatter to show as a fully cacheable time difference with JS, a time diff formatting option is provided. Part of that implementation was a "fallback configuration", labeled 'description'. No config schema was added for description, leading to situations where my CI build fails that validates configuration.
Steps to reproduce
Have schema validator enabled; add a timestamp field to a view; try saving the view. Expected: the view gets saved. Actual: a config schema validation exception is thrown.
Proposed resolution
Add schema for 'description' to Drupal core, core views and test views. (the MR does this).
Remaining tasks
Investigate and determine cause of failures mentioned in comment #16.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
TBD.
| Comment | File | Size | Author |
|---|---|---|---|
| #45 | 3400522-45.diff | 842 bytes | herved |
| #40 | core-3400522-time_diff-missing-schema.patch | 575 bytes | tiagoz |
| #28 | core-3400522-28.patch | 1.29 KB | graber |
| #9 | views.view_.time_diff_test.yml | 6.28 KB | agentrickard |
Issue fork drupal-3400522
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
Comment #2
heddnComment #5
boobaaComment #6
smustgrave commentedCan the rest of the issue summary be filled in please.
Also change caused test failures.
Comment #7
boobaaComment #8
heddnObviously we need tests added or this wouldn't have passed any if there were any. Tagging.
Comment #9
agentrickardHere's a simple view that shows the issue -- let me see if I can work up an MR.
Comment #10
agentrickardOK, here's what I did.
core/modules/node/tests/modules/node_test_views/test_views/views.view.test_field_created.ymlIf I read the code from
core/modules/node/tests/src/Functional/Views/NodeTestBase.php, the setup() method should try to import the new view and then auto-fail schema checks.If this test fails as I expect, then we can re-commit the patch.
Comment #11
smustgrave commentedThere's a test-only feature so don't need to push separately.
Comment #12
agentrickardWell, I suspect this minor issue may be covering up a more major problem (which we should file separately).
This is the YML from the test file:
This is the YML from core views.view_content
When the schema change was made in core, the affected core views were not updated. The following core views are potentially affected:
What does this potentially mean?
If the affected core views had been updated with the original change was made, tests would have caught the issue.
Comment #13
agentrickardHere's an updated MR that does the following:
* Removes the new test file
* Adds the `description` element to `views.view.content.yml`
Comment #14
agentrickardUpdate:
* This merge shows the issue (and the test fails) https://git.drupalcode.org/project/drupal/-/merge_requests/5505/diffs?co...
* Re-added the original patch / change
* Updated all affected views
Comment #15
smustgrave commentedSeems to have failures
But if we are updating all views will need an upgrade path for existing sites
Also not sure the title reflects what the MR is doing so tagged for that.
Comment #16
anybodyConfirming this issue, we just ran into it. Resaving the view adds the empty string.
Comment #18
haydenhuffman commentedI will update the title based on the MR and confirm the steps in the updated summary by EOD Monday 2024-07-29.
Comment #19
haydenhuffman commentedTitle updated, removing tag.
Comment #20
haydenhuffman commentedComment #21
haydenhuffman commentedSummary updated, removing tag.
Comment #22
sorlov commentedAdded hook_post_update_NAME() to update existing views with description for time_diff for timestamp formatter
need review
Comment #23
smustgrave commentedSee upgrade path but still needs upgrade test.
Comment #24
andypostComment #25
andypostThe test is incomplete but please combine it with checking that field is propagated after upgrade, so we can get rid of "Needs test" tag
Comment #26
graber commentedMaybe I'm missing something but:
Drupal\Core\Field\Plugin\Field\FieldFormatter::settingsForm()Description is just a user information element, it doesn't need a schema, how come it got to form state values and exported config in the first place?
Comment #27
graber commentedChanging this to:
fixes the config after save in views. So the issue is that "item" form element value gets to form state values as an empty string instead of not being passed there at all. On the other hand when saving on entity display settings form, description is not in the config (maybe there's a empty value filter).
And we need to get rid of those 'description' config values in time_diff everywhere.
Comment #28
graber commentedI'd do this. It's a very deep core form API change so let's see if it doesn't break anything.
Comment #29
graber commentedCreated #3467091: Item (display only) element results in an empty string in form_state values that addresses the root cause. Unfortunately, a few tests fail so it's not going to be that easy.
Comment #31
sorlov commentedOpened separate MR https://git.drupalcode.org/project/drupal/-/merge_requests/9250 for another solution
Issue was fixed by adding
'#input' => FALSE,to$form['time_diff']['description']So now we won't have empty
descriptionkey in formatter configComment #32
graber commentedNice one, but shouldn't we fix it in a more global way, adding it to item element defaults instead?
Comment #33
smustgrave commentedIf a new solution is used will need to update the issue summary, maybe? the title also.
Would need to check the criteria to see if this change is small enough to warrant not needing test coverage
Comment #34
andypostNew workaround point to problem with
itemform element inside of forms, git research points to #1825044: Turn contact form submissions into full-blown Contact Message entities, without storageSo I think if no other option to replace the element with
#markupfor example the !5505 looks nice idea but surely it needs follow-up to prevent export of this element to config at all, maybe event remove it at form state level via #3467091: Item (display only) element results in an empty string in form_state valuesPrevious code was
Comment #35
andypostIssue could be considered a duplicate if hack with input will be moved to contact module in #3467091: Item (display only) element results in an empty string in form_state values
Comment #36
sorlov commentedI'm not sure if this is global issue, related to any item element, cause for example, we have a lot of item elements in FileSystemForm form, but they are not exposed to config values
Comment #37
emptyvoid commentedJust updated code base to 11.2.0 and during database update got a long list of schema errors in almost all of the 50+ views in the system. And promptly both the admin views and interfaces and key site features generate 500 errors or white screens of death.
Except, I get 500 errors and white screens of death.. so not trivial.
I'd provide some details based on errors, but this issue white screens the dblog view so...
Reviewing the apache log directly it shows the same information bubbling up from the Drupal framework.
Warnings..
However, manually exporting the config for the view the fields and settings are exported with defaults.
Comment #38
emilorol commentedApplying path #28 solved the problem for me after resaving the field and then the view again without changing any of the two.
Some other warnings too about sequence as well after upgrading core to 11.2.1
Comment #39
tiagozturning #31 MR into patch
Comment #40
tiagozComment #41
ivnishWe need to choose one solution here
Comment #42
hitchshockMy opinion on this matter is as follows:
The patch #28 is more risky and dependent on many things on the site, and it's also a duplicate of #3467091: Item (display only) element results in an empty string in form_state values. We should leave this decision on hold on that ticket until it has been covered by tests and we are sure that it will not cause any new problems.
The solution from #30 just fixes an old issue, so it looks much better for me. And we can be sure that nothing else will be affected.
But, the patch is not ready yet. We need:
- a test that confirms that the issue exists and is now fixed
- upgrade path, to remove 'description' from the existing configs. Why? Because #2921810: Allow TimestampFormatter to show as a fully cacheable time difference with JS was released in 2023, and many configurations already contain this unexpected “description” property
Comment #45
herved commentedRebased MR 9250, attaching snapshot.