- Merge request !4Issue #3282091: php 8.1 Deprecated function: Return type of Drupal ReturnTypeWillChange β (Closed) created by Unnamed author
- πΊπΈUnited States gbirch
If you are getting the "Undefined array key "compare_format" in Drupal\name\Plugin\diff\Field\NameFieldBuilder->build()" warning, it appears that you can fix it by going to /admin/config/content/diff/fields and updating the configuration for any Name fields. Name does not provide a default diff format. Once you set one, the warning goes away.
- π¦πΉAustria maxilein
@gbirch that sounds great. But a name field on a user object is not listed there.
I also tried to resave all accounts - but it did not work
- πΊπΈUnited States gbirch
@maxilein The error from "NameFieldBuilder" is only going to come from a "name" field provided by the Name module (confusingly enough, the name of a user is not, in fact, a name field provided by the module). If you don't see a field listed on /admin/config/content/diff/fields that shows "Name" as its "Field Type," then are you sure you're really getting a NameFieldBuilder error? This is a field-level configuration problem, by the way - saving the user accounts (or any type of content) is never going to do anything for you. This is only solvable on the page mentioned.
- π¦πΉAustria maxilein
Following your suggestion I went to the field specification on the user type and saved it.
It only happens on update. Creating a new user does not cause problems.
I have attached a screenshot of the config of the only name field in use on the entire site.
Warning: Undefined array key "compare_format" in Drupal\name\Plugin\diff\Field\NameFieldBuilder->build() (line 73 of modules/contrib/name/src/Plugin/diff/Field/NameFieldBuilder.php). Drupal\name\Plugin\diff\Field\NameFieldBuilder->build(Object) (Line: 94) Drupal\diff\DiffEntityParser->parseEntity(Object) (Line: 104) Drupal\diff\DiffEntityComparison->compareRevisions(Object, Object) (Line: 181) Drupal\elogger\Services\Elogger->entityDiff(Object) (Line: 472) Drupal\elogger\Services\Elogger->prepareEntityLogMessage('entity_update', Object) (Line: 532) Drupal\elogger\Services\Elogger->logEvent('entity_update') (Line: 73) _log_entity_event('entity_update', Object) (Line: 50) elogger_entity_update(Object) call_user_func_array(Object, Array) (Line: 426) Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'elogger') (Line: 405) Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_update', Object) (Line: 433) Drupal\Core\Extension\ModuleHandler->invokeAll('entity_update', Array) (Line: 251) Drupal\Core\Entity\EntityStorageBase->invokeHook('update', Object) (Line: 900) Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object) (Line: 598) Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, 1) (Line: 781) Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, 1) (Line: 523) Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 804) Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 339) Drupal\Core\Entity\EntityBase->save() (Line: 46) Drupal\user\ProfileForm->save(Array, Object) call_user_func_array(Array, Array) (Line: 114) Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52) Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597) Drupal\Core\Form\FormBuilder->processForm('user_form', Array, Object) (Line: 325) Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73) Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39) Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object) call_user_func_array(Array, Array) (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718) Drupal\Core\DrupalKernel->handle(Object) (Line: 19) Warning: Undefined array key "compare_format" in Drupal\name\Plugin\diff\Field\NameFieldBuilder->build() (line 73 of modules/contrib/name/src/Plugin/diff/Field/NameFieldBuilder.php). Drupal\name\Plugin\diff\Field\NameFieldBuilder->build(Object) (Line: 94) Drupal\diff\DiffEntityParser->parseEntity(Object) (Line: 105) Drupal\diff\DiffEntityComparison->compareRevisions(Object, Object) (Line: 181) Drupal\elogger\Services\Elogger->entityDiff(Object) (Line: 472) Drupal\elogger\Services\Elogger->prepareEntityLogMessage('entity_update', Object) (Line: 532) Drupal\elogger\Services\Elogger->logEvent('entity_update') (Line: 73) _log_entity_event('entity_update', Object) (Line: 50) elogger_entity_update(Object) call_user_func_array(Object, Array) (Line: 426) Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'elogger') (Line: 405) Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_update', Object) (Line: 433) Drupal\Core\Extension\ModuleHandler->invokeAll('entity_update', Array) (Line: 251) Drupal\Core\Entity\EntityStorageBase->invokeHook('update', Object) (Line: 900) Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object) (Line: 598) Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, 1) (Line: 781) Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, 1) (Line: 523) Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 804) Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 339) Drupal\Core\Entity\EntityBase->save() (Line: 46) Drupal\user\ProfileForm->save(Array, Object) call_user_func_array(Array, Array) (Line: 114) Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52) Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597) Drupal\Core\Form\FormBuilder->processForm('user_form', Array, Object) (Line: 325) Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73) Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39) Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object) call_user_func_array(Array, Array) (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
- πΊπΈUnited States gbirch
@maxilein, this configuration has to be done in the settings for the diff module at https://YOUR_SITE/admin/config/content/diff/fields If you do not start at that URL, you are starting in the wrong place. See the attached image of the top of that page.
The picture you have attached is for the field settings form, which, again, is not the right place. You need DIFF settings.
Hope that helps.
- π¦πΉAustria maxilein
Thank you very much.
/admin/config/content/diff/fields has no USER entity.
The name field is a custom field on the user entity. - πΊπΈUnited States gbirch
@maxilein: Wow, I see the problem - while Name fields on content bundles are listed, Name fields on user entities are not. Sorry, I'm out of ideas here.
- π¦πΉAustria maxilein
Thank you. We should move this issue to diff module then I think.