Problem/Motivation
When trying to delete a destination the following error comes up "The website encountered an unexpected error. Please try again later"
On inspection of the logs the error details are below.
Error: Call to undefined method Drupal\login_destination\Entity\LoginDestination::getLabel() in Drupal\login_destination\Form\LoginDestinationDeleteRuleForm->getQuestion() (line 21 of /var/www/vhosts/example.com/modules/contrib/login_destination/src/Form/LoginDestinationDeleteRuleForm.php)
#0 /var/www/vhosts/example.com/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php(57): Drupal\login_destination\Form\LoginDestinationDeleteRuleForm->getQuestion()
#1 [internal function]: Drupal\Core\Entity\EntityConfirmFormBase->buildForm()
#2 /var/www/vhosts/example.com/core/lib/Drupal/Core/Form/FormBuilder.php(534): call_user_func_array()
#3 /var/www/vhosts/example.com/core/lib/Drupal/Core/Form/FormBuilder.php(281): Drupal\Core\Form\FormBuilder->retrieveForm()
#4 /var/www/vhosts/example.com/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#5 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#6 /var/www/vhosts/example.com/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#7 /var/www/vhosts/example.com/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#8 /var/www/vhosts/example.com/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#9 /var/www/vhosts/example.com/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#10 /var/www/vhosts/example.com/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#11 /var/www/vhosts/example.com/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#12 /var/www/vhosts/example.com/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#13 /var/www/vhosts/example.com/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#14 /var/www/vhosts/example.com/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#15 /var/www/vhosts/example.com/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#16 /var/www/vhosts/example.com/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#17 /var/www/vhosts/example.com/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#18 /var/www/vhosts/example.com/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#19 /var/www/vhosts/example.com/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
#20 /var/www/vhosts/example.com/index.php(19): Drupal\Core\DrupalKernel->handle()
#21 {main}
Steps to reproduce
Create a new destination then try to delete it
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | Cannot_delete_a_destination-3355386-7.patch | 1.09 KB | ammar qala |
| #6 | After_patch.png | 179.42 KB | akram khan |
| #6 | Before_patch.png | 723 KB | akram khan |
Issue fork login_destination-3355386
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
vinodhini.e commentedAm also facing this issue. Can anyone help with this?
Comment #5
rishi.kulshreshthaI have replaced the getLabel() method with the appropriate label() method, ensuring the correct invocation of the method for deleting the destination.
Comment #6
akram khanI reviewed the MR and it's resolved the issue. Additionally, I have attached before and after state screenshots for reference
Comment #7
ammar qala commentedIn case someone needs to apply #4 patch.
Comment #8
ammar qala commentedComment #9
rishi.kulshreshtha@Ammar Qala, thanks for your efforts but there's no need for a patch when someone can use https://git.drupalcode.org/project/login_destination/-/merge_requests/13...
Comment #10
keshavv commentedAs method
getLabel()is deprecated.We can use the MR.
It works well, +1 for RTBC
Comment #11
hockey2112 commentedThe patch in #8 worked for me.
Comment #14
rsvelko commentedpatch #8 and MR13 have same changes.
Just merged MR13.
All good now - just tested and after latest changes, we can delete rules again.