Problem/Motivation
Trying to add an office hour field on any entity in Drupal 11 gives the following error:
Drupal\Core\Field\FieldException: Attempted to create, modify or delete an instance of field with name field_office_hours on entity type node when the field storage does not exist. in Drupal\field\Entity\FieldConfig->getFieldStorageDefinition() (line 323 of core/modules/field/src/Entity/FieldConfig.php).
The module is freshly installed.
All other field types work without any issues.
Steps to reproduce
Thisis a problem with version 1.20 only, where the default widget is replaced from the 'normal' week widget (w/o exceptions and seasons) to the 'complex' widget.
This is introduced in #3495529: Change default widget and formatter, and repaired in version 1.21
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork office_hours-3497658
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
anybodyComment #3
kul.pratap commentedComment #4
anybody@kul.pratap any ideas? Otherwise let's leave this open to anyone who has one.
Comment #5
kul.pratap commented@anybody i am working on this.
Comment #6
johnvI (maintainer) encounter the same issue after upgrading to D11.
I installed my XAMPP stack, and noticed that the database driver is now 'sqlite', instead of 'mysql' before. That was also the only option when installing the new Drupa-11 environment. No idea why the mariaDB/mySQL was not present.
The database I created in phpMyAdmin is also still empty.
What driver are you using? Core fields can be created as before.
in D10:
in D11:
Comment #7
anybodyHi @johnv thank you! In our case that's definitely not the point. The database is the same as in Drupal 10 (MariaDB). And all other modules are working fine. So there must be a different reason in code here, I think.
I guess they choose SQLlite for demo installations as it comes with PHP and doesn't need additional configuration. But should be unrelated for sure.
Comment #8
johnvOTOH, the problem is generated by changing the ldefault widget in #3495529-8: Change default widget and formatter.
In OfficeHoursItem.php, setting the default widget back to
* default_widget = "office_hours_default",solves the problem.
But then, a following problem occurs..tbc.
Comment #9
anybodySorry I created the issue fork because I thought I found the reason, but didn't :(
Comment #10
kul.pratap commented"@johnv, as per #8, I have also changed the default_widget to office_hours_default, which solves the problem."
So should i create a MR with this change.
@anybody what are your suggestions?
Comment #11
anybodyWe should first find out why it fixes the issue - Our installation was fresh so it's not an upgrade path thing I think... @johnv should decide about a hotfix, please.
Comment #12
kul.pratap commented@anybody, the issue is that default_widget = "office_hours_exceptions", but there is no widget with the ID office_hours_exceptions. The widget ID is actually office_hours_exceptions_only, so we can change it accordingly.
Comment #13
anybody@kul.pratap I thought the same, but there is: https://git.drupalcode.org/issue/office_hours-3497658/-/blob/3497658-fie...
Comment #14
kul.pratap commentedWe have to identify the problem in this widget.
Comment #15
niklp commentedSimilar problem from another module, with a fix, related to db: https://www.drupal.org/project/iconify_field/issues/3496280
Might be helpful? I'm having the same problem.
Comment #16
anybodyNice @niklp!
https://git.drupalcode.org/project/iconify_field/-/commit/0ccf3125574b0c... looks like a change worth trying! Could you prepare the MR accordingly?
Comment #17
johnvThe problem is that the new default widget uses 'artificial' field definitions, that cannot not be created properly until the new fiedl definition is saved. The following patch circumvents that problem.
Comment #19
johnvThanks for your contribution.
Comment #20
johnvComment #21
johnvA new release 1.21 is now released.