Suspected unreleased regression in Custom File Field handling

Created on 13 December 2024, 6 days ago

1.0 Problem/Motivation

It looks like there is an error introduced here
https://github.com/colemanw/webform_civicrm/pull/1009/files#r1883075363

Whereby we get a warning post submission saying that $newFilename isn't defined.

I still see the file on the activity. I'm not sure if this is actually breaking anything. However it seems bad that this warning shows.

I'm guessing from a quick scan that this might get worse if there was multi page in play?


Warning: Undefined variable $newFilename in Drupal\webform_civicrm\WebformCivicrmPostProcess->fillDataFromSubmission() (line 2560 of [siteroot]/web/modules/contrib/webform_civicrm/src/WebformCivicrmPostProcess.php)

#0 [siteroot]/web/core/includes/bootstrap.inc(166): _drupal_error_handler_real()
#1 [siteroot]/web/modules/contrib/webform_civicrm/src/WebformCivicrmPostProcess.php(2560): _drupal_error_handler()
#2 [siteroot]/web/modules/contrib/webform_civicrm/src/WebformCivicrmPostProcess.php(205): Drupal\webform_civicrm\WebformCivicrmPostProcess->fillDataFromSubmission()
#3 [siteroot]/web/modules/contrib/webform_civicrm/src/Plugin/WebformHandler/CivicrmWebformHandler.php(152): Drupal\webform_civicrm\WebformCivicrmPostProcess->preSave()
#4 [siteroot]/web/modules/contrib/webform/src/Entity/Webform.php(2758): Drupal\webform_civicrm\Plugin\WebformHandler\CivicrmWebformHandler->preSave()
#5 [siteroot]/web/modules/contrib/webform/src/WebformSubmissionStorage.php(1214): Drupal\webform\Entity\Webform->invokeHandlers()
#6 [siteroot]/web/modules/contrib/webform/src/WebformSubmissionStorage.php(970): Drupal\webform\WebformSubmissionStorage->invokeWebformHandlers()
#7 [siteroot]/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(483): Drupal\webform\WebformSubmissionStorage->doPreSave()
#8 [siteroot]/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(806): Drupal\Core\Entity\EntityStorageBase->save()
#9 [siteroot]/web/modules/contrib/webform/src/WebformSubmissionStorage.php(985): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()
#10 [siteroot]/web/core/lib/Drupal/Core/Entity/EntityBase.php(354): Drupal\webform\WebformSubmissionStorage->save()
#11 [siteroot]/web/modules/contrib/webform/src/Entity/WebformSubmission.php(913): Drupal\Core\Entity\EntityBase->save()
#12 [siteroot]/web/modules/contrib/webform/src/WebformSubmissionForm.php(2017): Drupal\webform\Entity\WebformSubmission->save()
#13 [internal function]: Drupal\webform\WebformSubmissionForm->save()
#14 [siteroot]/web/core/lib/Drupal/Core/Form/FormSubmitter.php(129): call_user_func_array()
#15 [siteroot]/web/core/lib/Drupal/Core/Form/FormSubmitter.php(67): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers()
#16 [siteroot]/web/core/lib/Drupal/Core/Form/FormBuilder.php(597): Drupal\Core\Form\FormSubmitter->doSubmitForm()
#17 [siteroot]/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm()
#18 [siteroot]/web/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm()
#19 [siteroot]/web/modules/contrib/webform/src/Entity/Webform.php(1250): Drupal\Core\Entity\EntityFormBuilder->getForm()
#20 [siteroot]/web/modules/contrib/webform/src/Controller/WebformEntityController.php(89): Drupal\webform\Entity\Webform->getSubmissionForm()
#21 [internal function]: Drupal\webform\Controller\WebformEntityController->addForm()
#22 [siteroot]/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#23 [siteroot]/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#24 [siteroot]/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#25 [siteroot]/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#26 [siteroot]/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#27 [siteroot]/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#28 [siteroot]/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#29 [siteroot]/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#30 [siteroot]/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#31 [siteroot]/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#32 [siteroot]/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#33 [siteroot]/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#34 [siteroot]/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#35 [siteroot]/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#36 [siteroot]/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#37 [siteroot]/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#38 [siteroot]/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#39 [siteroot]/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#40 {main}

2.0 Detailed steps to reproduce (embed screenshots)

Fresh D10 install. Install civicrm webform_civicrm and webform_ui modules (dev version of webform_civicrm from github)

In CiviCRM Create custom field group on activity, add a custom file field, remove existing contact.
Create webform add the custom field
Submit form with data in it.
See warning (depending on your config

3.0 Proposed resolution

Fix code so we don't assume that newFilename is populated if it is not.

🐛 Bug report
Status

Active

Version

6.0

Component

Webform/Drupal

Created by

🇳🇿New Zealand luke.stewart

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024