- Issue created by @mattbloomfield
Sorry, should have posted this along with it. This was the error I was getting when trying to visit the site or use drush:
In Drupal.php line 169:
\Drupal::$container is not initialized yet. \Drupal::setContainer() must be
called with a real container.- 🇳🇱Netherlands johnv
How about this test upfront:
diff --git a/office_hours.module b/office_hours.module index f3b535e..59bc7ff 100644 --- a/office_hours.module +++ b/office_hours.module @@ -9,12 +9,15 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\office_hours\Plugin\Field\FieldType\OfficeHoursItemBase; +// Include file, avoiding container error during upgrade. +if (\Drupal::hasContainer()) { // Add theme.api.php hooks. \Drupal::moduleHandler()->loadInclude('office_hours', 'inc', 'office_hours.theme'); // Add ExceptionItem field formatter theming/preprocessing. \Drupal::moduleHandler()->loadInclude('office_hours', 'inc', 'office_hours.theme.exceptions'); // Add views hooks. \Drupal::moduleHandler()->loadInclude('office_hours', 'inc', 'office_hours.views'); +} /** * Implements hook_help().
Sure, you're a maintainer so you'd know the code much better than I would. I just hope I helped in some small way.
- 🇳🇱Netherlands johnv
Indeed, but I am not in the process of updating, so perhaps you chan check in the next run.
- 🇨🇳China 司南
hook implements in these inc files will be ignored, if \Drupal::hasContainer() return false when the .module file is load by drupal core.
- 🇳🇱Netherlands johnv
Indeed, that is exactly the purpose. The files are not needed during upgrade. They will be loaded upon the next run, do they not?
Do you have a coding suggestion?
- 🇳🇱Netherlands johnv
Putting this on Fixed, until it is reported that the committed solution does not solve the problem.