Problem/Motivation
Adding content via paragraphs where layout paragraphs is enabled (though not used in this instance).
From error report:
http://localhost/drupal9/web/layout-paragraphs-builder/fpBN0hZhOedkp4MBn...
Referrer http://localhost/drupal9/web/node/add/photo_article
Message Deprecated function: mb_strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Html::getId() (line 219 of D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Component\Utility\Html.php)
#0 D:\xampp\htdocs\drupal9\web\core\includes\bootstrap.inc(346): _drupal_error_handler_real(8192, 'mb_strtolower()...', 'D:\\xampp\\htdocs...', 219)
#1 [internal function]: _drupal_error_handler(8192, 'mb_strtolower()...', 'D:\\xampp\\htdocs...', 219)
#2 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Component\Utility\Html.php(219): mb_strtolower(NULL)
#3 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Component\Utility\Html.php(176): Drupal\Component\Utility\Html::getId(NULL)
#4 D:\xampp\htdocs\drupal9\web\modules\contrib\layout_paragraphs\src\Element\LayoutParagraphsBuilder.php(284): Drupal\Component\Utility\Html::getUniqueId(NULL)
#5 D:\xampp\htdocs\drupal9\web\modules\contrib\layout_paragraphs\src\Element\LayoutParagraphsBuilder.php(190): Drupal\layout_paragraphs\Element\LayoutParagraphsBuilder->buildComponent(Object(Drupal\layout_paragraphs\LayoutParagraphsComponent), 'default')
#6 [internal function]: Drupal\layout_paragraphs\Element\LayoutParagraphsBuilder->preRender(Array)
#7 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\Security\DoTrustedCallbackTrait.php(101): call_user_func_array(Array, Array)
#8 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\Render\Renderer.php(772): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
#9 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\Render\Renderer.php(363): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#10 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\Render\Renderer.php(201): Drupal\Core\Render\Renderer->doRender(Array, true)
#11 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\Render\Renderer.php(145): Drupal\Core\Render\Renderer->render(Array, true)
#12 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\Render\Renderer.php(564): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
#13 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\Render\Renderer.php(146): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#14 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\Ajax\CommandWithAttachedAssetsTrait.php(36): Drupal\Core\Render\Renderer->renderRoot(Array)
#15 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\Ajax\ReplaceCommand.php(31): Drupal\Core\Ajax\InsertCommand->getRenderedContent()
#16 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\Ajax\AjaxResponse.php(43): Drupal\Core\Ajax\ReplaceCommand->render()
#17 D:\xampp\htdocs\drupal9\web\modules\contrib\layout_paragraphs\src\LayoutParagraphsLayoutRefreshTrait.php(75): Drupal\Core\Ajax\AjaxResponse->addCommand(Object(Drupal\Core\Ajax\ReplaceCommand))
#18 D:\xampp\htdocs\drupal9\web\modules\contrib\layout_paragraphs\src\Form\InsertComponentForm.php(139): Drupal\layout_paragraphs\Form\ComponentFormBase->refreshLayout(Object(Drupal\Core\Ajax\AjaxResponse))
#19 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\Ajax\AjaxFormHelperTrait.php(39): Drupal\layout_paragraphs\Form\InsertComponentForm->successfulAjaxSubmit(Array, Object(Drupal\Core\Form\FormState))
#20 [internal function]: Drupal\layout_paragraphs\Form\ComponentFormBase->ajaxSubmit(Array, Object(Drupal\Core\Form\FormState), Object(Symfony\Component\HttpFoundation\Request))
#21 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\Form\FormAjaxResponseBuilder.php(69): call_user_func_array(Array, Array)
#22 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber.php(109): Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse(Object(Symfony\Component\HttpFoundation\Request), Array, Object(Drupal\Core\Form\FormState), Array)
#23 [internal function]: Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber->onException(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#24 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#25 D:\xampp\htdocs\drupal9\vendor\symfony\http-kernel\HttpKernel.php(219): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...')
#26 D:\xampp\htdocs\drupal9\vendor\symfony\http-kernel\HttpKernel.php(91): Symfony\Component\HttpKernel\HttpKernel->handleThrowable(Object(Drupal\Core\Form\FormAjaxException), Object(Symfony\Component\HttpFoundation\Request), 1)
#27 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\StackMiddleware\Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 D:\xampp\htdocs\drupal9\web\core\modules\page_cache\src\StackMiddleware\PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 D:\xampp\htdocs\drupal9\web\core\modules\page_cache\src\StackMiddleware\PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 D:\xampp\htdocs\drupal9\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#34 D:\xampp\htdocs\drupal9\web\core\lib\Drupal\Core\DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#35 D:\xampp\htdocs\drupal9\web\index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#36 {main}
Steps to reproduce
Create new content using a specific content type. All works, but this appears in error reports.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork layout_paragraphs-3276855
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
avpadernoComment #5
lolgm commentedI was having the same error. I believe the patch in the merge request above solves the problem.
I don't know if this is the correct approach, but suggestions are welcome.
Comment #6
anybodyThank you, I think @justin2pin should have a look at the MR's details. I'm sure they fix the issue, but only 90% sure it's the right way.
Thanks!
Comment #7
anybody@lolgm where does this ->uuid approach come from? Is the same used somewhere else, for example in paragraphs? That would help to rate the fix. Thanks :)
Comment #8
hudriA new, not-yet-saved paragraph also does not have an ID yet (it is not yet stored in the
paragraphs_itemDB table), but it does have an UUID (as used by the tempstore). Given this change inbuildComponents()does the same as the callingpreRender()functionusing the UUID seems a sensible fallback for me.
Comment #9
lolgm commented@Anybody As said by @hudri a newly created paragraph doesn't have an ID, I addressed the question as adding the only possible unique identifier for these cases.
Should we just replace the ID value with the UUID value (
#attributes)? That way we don't mix IDs with UUIDs, although I don't know what would be the impact of this...Remembering that the original data is always stored in the following attributes:
Comment #11
justin2pin commentedThanks for this. MR!86 was fine as-is, but I simplified it slightly. The ID is arbitrary and just needs to be non-null... passing an empty string would work just as well, but might be a little harder for developers to read in the future. I'm adding tests for PHP 8.1, which I believe is the PHP version where this warning is introduced.
I think this also needs to be an issue in core with correct typecasting for the $id parameter in Html::getUniqueId().
Once tests finish, I'll commit. Thanks again.
Comment #13
justin2pin commented