Hi!
My Drupal version is 9.3.7 and I'm using Login destination 8.x-2.0-beta1 with PHP 8.1 installed.
When /admin/config/people/login-destination/add is opened I receive warning:
Deprecated function: parse_url(): Passing null to parameter #1 ($url) of type string is deprecated in Drupal\login_destination\Form\LoginDestinationRuleForm->getUriAsDisplayableString() (line 266 of modules/contrib/login_destination/src/Form/LoginDestinationRuleForm.php).
Drupal\login_destination\Form\LoginDestinationRuleForm->getUriAsDisplayableString(NULL) (Line: 106)
Drupal\login_destination\Form\LoginDestinationRuleForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 531)
Drupal\Core\Form\FormBuilder->retrieveForm('login_destination_add_form', Object) (Line: 278)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
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: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
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: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Is there any patch to update parse_url() function?
Comments
Comment #2
almador commentedComment #3
victoria-marina commentedI'll work on this.
Comment #4
victoria-marina commentedI made a patch, hope it helps! Please, review it.
Comment #5
almador commentedthanks, Victoria-Marina!
one more error:
Comment #6
victoria-marina commented@almador can you put here the steps to reproduce this error?
Comment #7
almador commented@victoria-marina
1. install Login destination 8.x-2.0-beta1 on Drupal version is 9.7.3 with PHP 8.1
2. visit /admin/config/people/login-destination
Comment #8
victoria-marina commented@almador Sorry, but the error isn't showing.
Comment #9
almador commented@victoria-marina
Does your php is 8.1.3?
And what is your settings at /admin/config/development/logging ?
Comment #10
victoria-marina commented@almador "All messages".
Comment #11
almador commented@victoria-marina my settings is "All messages, with backtrace information", but I'm not sure that's the reason
Comment #12
almador commentedI've found Html::escape in
src/Entity/LoginDestination.phpTried to replace
Html::escape($label);withHtml::escape($label ?? '');, but it doesn't solved the issue.Comment #13
victoria-marina commented@almador Actually I don't think this is related to this module. Because on the error message, there isn't a path related to the module. On the first error, we got this path:
modules/contrib/login_destination/src/Form/LoginDestinationRuleForm.phpComment #14
almador commented@victoria-marina, but this error appears only at /admin/config/people/login-destination
and as I said before "I've found Html::escape in src/Entity/LoginDestination.php"
p.s. Seems that this patch could solve the issue
https://www.drupal.org/files/issues/2022-03-06/escape-3268036.patch
It is from https://www.drupal.org/project/drupal/issues/3268036
If someone wants to add this patches, here is the part of my composer.json:
Comment #15
almador commentedComment #16
darvanenBacktrace shows this is happening when building the form, it is definitely triggered by the module passing an empty string to
getUriAsDisplayableString:This is because when the form is empty
$login_destination->getDestination()returns null.The simplest and easiest to read fix is to abort all the checks if presented with an empty value. Patch attached.
Comment #18
rsvelko commentedThanks everyone! Patch applied, commited and pushed. The newest module release contains it.