Undefined Method URL::getUrl()

Created on 6 April 2024, 3 months ago
Updated 10 April 2024, 3 months ago

Problem/Motivation

There are two problems here. There's an issue with the code. There's also an issue with the development process.

CODE PROBLEM

https://git.drupalcode.org/project/social/-/blame/12.2.4/modules/social_...

$route_group_add is a \Drupal\Core\Url object, from either the assignment on line 2555 or the service call on line 2564. The Url class doesn't have a getUrl() method.

THE IDE AND PROCESS PROBLEM

Shit happens (: It's ok. It's a good opportunity to learn where you can do better.

There is a serious issue in your Dev/QA process. The developer's IDE should have thrown an error when he tried to use a method that doesn't exist. And, the QA team should have caught a fatal code error. This code error should never have made it into a production tagged version of Open Social.

Steps to reproduce

I upgraded an OpenSocial site from 12.1.x to 12.2.x. I got a whitescreen on the homepage as the admin user.

Proposed resolution

I upgraded to 12.3.x and the problem went away because the code is fixed.

Remaining tasks

- Backport the fix from 12.3.x to 12.2.x.
- Figure out how a fatal code error got into a tagged distribution of OpenSocial and fix the process problem.

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

12.2

Component

Code (back-end)

Created by

🇺🇸United States JasonSafro

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

Comments & Activities

  • Issue created by @JasonSafro
  • 🇺🇸United States JasonSafro

    Here's the full error backtrace:

    The website encountered an unexpected error. Try again later.

    Error: Call to undefined method Drupal\Core\Url::getUrl() in social_group_social_user_account_header_create_links() (line 2575 of profiles/contrib/social/modules/social_features/social_group/social_group.module).

    call_user_func_array(Object, Array) (Line: 409)
    Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'social_group') (Line: 388)
    Drupal\Core\Extension\ModuleHandler->invokeAllWith('social_user_account_header_create_links', Object) (Line: 416)
    Drupal\Core\Extension\ModuleHandler->invokeAll('social_user_account_header_create_links', Array) (Line: 160)
    Drupal\social_user\Plugin\Block\AccountHeaderBlock->build() (Line: 171)
    Drupal\block\BlockViewBuilder::preRender(Array)
    call_user_func_array('Drupal\block\BlockViewBuilder::preRender', Array) (Line: 111)
    Drupal\Core\Render\Renderer->doTrustedCallback('Drupal\block\BlockViewBuilder::preRender', Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725 ', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 859)
    Drupal\Core\Render\Renderer->doCallback('#pre_render', 'Drupal\block\BlockViewBuilder::preRender', Array) (Line: 421)
    Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 240)
    Drupal\Core\Render\Renderer->render(Array, 1) (Line: 165)
    Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 166)
    Drupal\Core\Render\Renderer->renderPlain(Array) (Line: 183)
    Drupal\Core\Render\Renderer->doRenderPlaceholder(Array) (Line: 712)
    Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
    Fiber->start() (Line: 720)
    Drupal\Core\Render\Renderer->replacePlaceholders(Array) (Line: 597)
    Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 240)
    Drupal\Core\Render\Renderer->render(Array, 1) (Line: 153)
    Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 154)
    Drupal\Core\Render\Renderer->renderRoot(Array) (Line: 286)
    Drupal\Core\Render\HtmlResponseAttachmentsProcessor->renderPlaceholders(Object) (Line: 135)
    Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments(Object) (Line: 45)
    Drupal\Core\EventSubscriber\HtmlResponseSubscriber->onRespond(Object, 'kernel.response', Object)
    call_user_func(Array, Object, 'kernel.response', Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.response') (Line: 214)
    Symfony\Component\HttpKernel\HttpKernel->filterResponse(Object, Object, 1) (Line: 160)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    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: 28)
    Drupal\Core\StackMiddleware\ContentLength->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: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

  • Assigned to abhishek_virasat
  • Issue was unassigned.
  • Status changed to Needs review 3 months ago
  • 🇮🇳India abhishek_virasat

    I have fixed the issue and created Patch. please review it once

Production build 0.69.0 2024