Issue after save contact on Drupal

Created on 5 May 2023, over 1 year ago
Updated 3 August 2023, over 1 year ago

Problem/Motivation

I have data mapped to be synced from both SF to Drupal and Drupal to SF.

Normally when I update user info the save is synced with SF, this was working fine in version 5.0.0.

When upgrading to version 5.0.2 it is giving me the following error

TypeError: strlen(): Argument #1 ($string) must be of type string, array given in strlen() (line 245 of /app/web/modules/contrib/salesforce/modules/salesforce_mapping/src/SalesforceMappingFieldPluginBase.php)
#0 /app/web/modules/contrib/salesforce/modules/salesforce_mapping/src/SalesforceMappingFieldPluginBase.php(245): strlen(Array)
#1 /app/web/modules/contrib/salesforce/modules/salesforce_mapping/src/PushParams.php(55): Drupal\salesforce_mapping\SalesforceMappingFieldPluginBase->pushValue(Object(Drupal\user\Entity\User), Object(Drupal\salesforce_mapping\Entity\SalesforceMapping))
#2 /app/web/modules/contrib/salesforce/modules/salesforce_mapping/src/Entity/MappedObject.php(398): Drupal\salesforce_mapping\PushParams->__construct(Object(Drupal\salesforce_mapping\Entity\SalesforceMapping), Object(Drupal\user\Entity\User))
#3 /app/web/modules/contrib/salesforce/modules/salesforce_push/salesforce_push.module(172): Drupal\salesforce_mapping\Entity\MappedObject->push()
#4 /app/web/modules/contrib/salesforce/modules/salesforce_push/salesforce_push.module(84): salesforce_push_entity_crud_mapping(Object(Drupal\user\Entity\User), 'push_update', Object(Drupal\salesforce_mapping\Entity\SalesforceMapping))
#5 /app/web/modules/contrib/salesforce/modules/salesforce_push/salesforce_push.module(29): salesforce_push_entity_crud(Object(Drupal\user\Entity\User), 'push_update')
#6 [internal function]: salesforce_push_entity_update(Object(Drupal\user\Entity\User))
#7 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(426): call_user_func_array(Object(Closure), Array)
#8 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(405): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object(Closure), 'salesforce_push')
#9 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(433): Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_update', Object(Closure))
#10 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(251): Drupal\Core\Extension\ModuleHandler->invokeAll('entity_update', Array)
#11 /app/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(903): Drupal\Core\Entity\EntityStorageBase->invokeHook('update', Object(Drupal\user\Entity\User))
#12 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(598): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object(Drupal\user\Entity\User))
#13 /app/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(784): Drupal\Core\Entity\EntityStorageBase->doPostSave(Object(Drupal\user\Entity\User), true)
#14 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(523): Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object(Drupal\user\Entity\User), true)
#15 /app/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(804): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\user\Entity\User))
#16 /app/web/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object(Drupal\user\Entity\User))
#17 /app/web/core/modules/user/src/ProfileForm.php(46): Drupal\Core\Entity\EntityBase->save()
#18 [internal function]: Drupal\user\ProfileForm->save(Array, Object(Drupal\Core\Form\FormState))
#19 /app/web/core/lib/Drupal/Core/Form/FormSubmitter.php(114): call_user_func_array(Array, Array)
#20 /app/web/core/lib/Drupal/Core/Form/FormSubmitter.php(52): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState))
#21 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(595): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState))
#22 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(323): Drupal\Core\Form\FormBuilder->processForm('user_form', Array, Object(Drupal\Core\Form\FormState))
#23 /app/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\user\ProfileForm), Object(Drupal\Core\Form\FormState))
#24 /app/web/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#25 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#26 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#27 /app/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#28 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#29 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#30 /app/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#31 /app/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#32 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#34 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#35 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#36 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#37 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#38 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#39 /app/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#40 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#41 {main}

I ran drush updb and drush cr but it still gives the same error

Steps to reproduce

Edit a user that is mapped with synchronization to Salesforce, when saving the user the error appears

🐛 Bug report
Status

Needs work

Version

5.0

Component

salesforce_mapping.module

Created by

🇪🇨Ecuador cacrody

Live updates comments and jobs are added and updated live.
  • PHP 8.0

    The issue particularly affects sites running on PHP version 8.0.0 or later.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany spuky

    Are you sure you have not also updated the PHP Version to 8.

    It looks like an PHP 8 Error.

    It seems that you have al Multivalue field on your user that is mapped to a Regular field in Salesforce maybe try removing Field mappings one by one till it works... it would be nice to know what kind off Field it is on both sides...

  • 🇫🇷France perraudeau France

    Hello, I have the same issue with the phone number field which is an array and not a string. And the $field_definition['type'] for 'phone' is not specified, so the default string is used.

  • 🇫🇷France perraudeau France

    The patch i applied to fix my issue with the advanced phone field.

  • 🇪🇨Ecuador cacrody

    I discovered that one of the user fields I have for my site that is of type String is trailing the value of $value[0].

    I will upload a patch in case another user has the same problem.

Production build 0.71.5 2024