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

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

anybody created an issue. See original summary.

anybody’s picture

Issue summary: View changes
kul.pratap’s picture

Assigned: Unassigned » kul.pratap
anybody’s picture

Assigned: kul.pratap » Unassigned

@kul.pratap any ideas? Otherwise let's leave this open to anyone who has one.

kul.pratap’s picture

@anybody i am working on this.

johnv’s picture

I (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:

/*
$databases['default']['default'] = array (
  'database' => 'd10_20230821',
  'username' => 'root',
  'password' => '',
  'prefix' => '',
  'host' => 'localhost',
  'port' => '3306',
  'isolation_level' => 'READ COMMITTED',
  'namespace' => 'Drupal\\mysql\\Driver\\Database\\mysql',
  'driver' => 'mysql',
  'autoload' => 'core/modules/mysql/src/Driver/Database/mysql/',
);

in D11:

$databases['default']['default'] = array (
  'database' => 'd11_20250110',
  'prefix' => '',
  'driver' => 'sqlite',
  'namespace' => 'Drupal\\sqlite\\Driver\\Database\\sqlite',
  'autoload' => 'core/modules/sqlite\\src\\Driver\\Database\\sqlite\\',
);
anybody’s picture

Hi @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.

johnv’s picture

OTOH, 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.

anybody’s picture

Sorry I created the issue fork because I thought I found the reason, but didn't :(

kul.pratap’s picture

"@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?

anybody’s picture

We 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.

kul.pratap’s picture

@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.

anybody’s picture

kul.pratap’s picture

We have to identify the problem in this widget.

niklp’s picture

Similar 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.

anybody’s picture

Version: 8.x-1.20 » 8.x-1.x-dev

Nice @niklp!

https://git.drupalcode.org/project/iconify_field/-/commit/0ccf3125574b0c... looks like a change worth trying! Could you prepare the MR accordingly?

johnv’s picture

Title: 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 » FieldException error when creating an office_hours field on v8.x-1.20

The 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.

  • johnv committed 224755b9 on 8.x-1.x
    Issue #3497658 by anybody, kul.pratap, johnv, niklp: FieldException...
johnv’s picture

Version: 8.x-1.x-dev » 8.x-1.20
Status: Active » Fixed

Thanks for your contribution.

johnv’s picture

johnv’s picture

A new release 1.21 is now released.

Status: Fixed » Closed (fixed)

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