I have installed the module and installed Views module, too.
After I have saved the field, I get this error message.

TypeError: Unsupported operand types: array + null in Drupal\office_hours\Plugin\views\field\FieldBase::viewsFieldData() (line 81 of modules/contrib/office_hours/src/Plugin/views/field/FieldBase.php).
office_hours_field_views_data()
call_user_func_array() (Line: 400)
Drupal\Core\Extension\ModuleHandler->invoke() (Line: 193)
views_views_data() (Line: 236)
Drupal\views\ViewsData->Drupal\views\{closure}() (Line: 388)
Drupal\Core\Extension\ModuleHandler->invokeAllWith() (Line: 244)
Drupal\views\ViewsData->getData() (Line: 154)
Drupal\views\ViewsData->get() (Line: 1191)
Drupal\views\ViewExecutable->initQuery() (Line: 885)
Drupal\views\Plugin\views\display\DisplayPluginBase->getHandlers() (Line: 1055)
Drupal\views\ViewExecutable->_initHandler() (Line: 913)
Drupal\views\ViewExecutable->initHandlers() (Line: 2330)
Drupal\views\Plugin\views\display\DisplayPluginBase->preExecute() (Line: 1707)
Drupal\views\ViewExecutable->preExecute() (Line: 1642)
Drupal\views\ViewExecutable->executeDisplay() (Line: 81)
Drupal\views\Element\View::preRenderViewElement()
call_user_func_array() (Line: 111)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 797)
Drupal\Core\Render\Renderer->doCallback() (Line: 386)
Drupal\Core\Render\Renderer->doRender() (Line: 204)
Drupal\Core\Render\Renderer->render() (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 239)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 704)
Drupal\Core\DrupalKernel->handle() (Line: 19)

I hope someone can help me. I can no longer uninstall the module either.
Thank you very much...

Drupal 10.1.8
PHP 8.1.27

CommentFileSizeAuthor
#4 office_hours-3421574.patch717 bytesabhishek_gupta1

Comments

Nickstedt created an issue. See original summary.

Nickstedt’s picture

Issue summary: View changes
abhishek_gupta1’s picture

Assigned: Unassigned » abhishek_gupta1
abhishek_gupta1’s picture

Assigned: abhishek_gupta1 » Unassigned
Status: Active » Needs review
StatusFileSize
new717 bytes

@Nickstedt , I have fixed the issue . please kindly review the patch file

  • johnv committed 5057d4ca on 8.x-1.x
    Issue #3421574: TypeError: Unsupported operand types: array + null /...
johnv’s picture

Version: 8.x-1.13 » 8.x-1.14
Priority: Normal » Major
Status: Needs review » Fixed

The patch does not add the data in both cases.
i used the following construct:

  $field_data['field'] ??= [];
  $field_data['field'] += $data[$table_name]['delta']['field'];

Since it breaks you system, i will release now.

rang501’s picture

I just updated to 1.15 and it seems to be broken

TypeError: Unsupported operand types: array + null in Drupal\office_hours\Plugin\views\field\FieldBase::viewsFieldData() (line 81 of modules/contrib/office_hours/src/Plugin/views/field/FieldBase.php).

ethangeorgi’s picture

Ditto: we just updated to 1.15 and it seems to be broken for us as well. I don't see that the patch, or the "construct," are in the new code.

johnv’s picture

Status: Fixed » Needs work

Please make sure that you truly have 1.15. It was released shortly after 1.14, which does not have the patch.
Also make sure that all caches are refreshed.
Please report back. I will check again.

ethangeorgi’s picture

Sure. I just ran composer update and it had nothing new.

composer info drupal/office_hours
name : drupal/office_hours
descrip. : Defines a 'weekly office hours' field type, allowing you to specify when an Entity is open or closed.
keywords :
versions : * 1.15.0
type : drupal-module
license : GNU General Public License v2.0 or later (GPL-2.0+) (OSI approved) https://spdx.org/licenses/GPL-2.0+.html#licenseText
homepage : http://drupal.org/project/office_hours
source : [git] https://git.drupalcode.org/project/office_hours.git 8.x-1.15
dist : [zip] https://ftp.drupal.org/files/projects/office_hours-8.x-1.15.zip 8.x-1.15
path : /Users/ethan/Documents/Lando/rpi-registrar/web/modules/contrib/office_hours
names : drupal/office_hours

Drupal Available Updates Report says
Office Hours 8.x-1.15
Includes: Office Hours

Flushing the cache gives me
The website encountered an unexpected error. Try again later.

drush ws gives me
3158 16/Feb 07:57 php Error TypeError: Unsupported operand types: array + null in Drupal\office_hours\Plugin\views\field\FieldBase::viewsFieldData() (line 81 of /app/web/modules/contrib/office_hours/src/Plugin/views/

  • johnv committed b9ad4bec on 8.x-1.x
    Issue #3421574: TypeError: Unsupported operand types: array + null /...
johnv’s picture

Title: TypeError: Unsupported operand types: array + null / FieldBase.php » TypeError: Unsupported operand types: array + null / Views FieldBase.php
Issue summary: View changes

Please test new dev version.

The patch removes the error message, but does not resolve the root cause.
I do not understand this this can happen.
You may have problems using the new 'season' and 'timeslot' fields in Views (to be used as columns in a view).

ethangeorgi’s picture

The dev version works for me. The site I'm testing with loads now, without errors. It was not using new "season" fields.

I can see the new code from the patch in this version of FieldBase.php, and I couldn't in 1.15, so that looks better.

I am concerned about "does not resolve the root cause."

Thanks for your work on this!

johnv’s picture

Version: 8.x-1.14 » 8.x-1.15
Status: Needs work » Fixed

Thanks for your help.

Status: Fixed » Closed (fixed)

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

johnv’s picture

Title: TypeError: Unsupported operand types: array + null / Views FieldBase.php » Views FieldBase.php TypeError: Unsupported operand types: array + null
Component: Code » Integrating Views