Problem/Motivation

When run on Drupal 9, we're getting the following error:

PHP Errors were logged:
Error: Call to undefined method Drupal\file\Entity\File::url() in representative_image_tokens() (line 60 of /opt/drupal/web/modules/contrib/representative_image/representative_image.module)
#0 [internal function]: representative_image_tokens('node', Array, Array, Array, Object(Drupal\Core\Render\BubbleableMetadata))
#1 /opt/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(403): call_user_func_array('representative_...', Array)
#2 /opt/drupal/web/core/lib/Drupal/Core/Utility/Token.php(304): Drupal\Core\Extension\ModuleHandler->invokeAll('tokens', Array)
#3 /opt/drupal/web/core/lib/Drupal/Core/Utility/Token.php(196): Drupal\Core\Utility\Token->generate('node', Array, Array, Array, Object(Drupal\Core\Render\BubbleableMetadata))
#4 /opt/drupal/web/modules/contrib/metatag/src/MetatagToken.php(66): Drupal\Core\Utility\Token->replace('[node:represent...', Array, Array, Object(Drupal\Core\Render\BubbleableMetadata))
#5 /opt/drupal/web/modules/contrib/metatag/src/MetatagManager.php(577): Drupal\metatag\MetatagToken->replace('[node:represent...', Array, Array, NULL)
#6 /opt/drupal/web/modules/contrib/metatag/src/MetatagManager.php(493): Drupal\metatag\MetatagManager->generateRawElements(Array, Object(Drupal\node\Entity\Node))
#7 /opt/drupal/web/modules/contrib/metatag/metatag.module(496): Drupal\metatag\MetatagManager->generateElements(Array, Object(Drupal\node\Entity\Node))
#8 /opt/drupal/web/modules/contrib/metatag/metatag.module(265): metatag_get_tags_from_route()
#9 /opt/drupal/web/modules/contrib/metatag/metatag.module(234): _metatag_remove_duplicate_entity_tags(Array)
#10 /opt/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(539): metatag_entity_view_alter(Array, Object(Drupal\node\Entity\Node), Object(Drupal\Core\Entity\Entity\EntityViewDisplay))
#11 /opt/drupal/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(305): Drupal\Core\Extension\ModuleHandler->alter('node_view', Array, Object(Drupal\node\Entity\Node), Object(Drupal\Core\Entity\Entity\EntityViewDisplay))
#12 /opt/drupal/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(239): Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array)
#13 [internal function]: Drupal\Core\Entity\EntityViewBuilder->build(Array)
#14 /opt/drupal/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array(Array, Array)
#15 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(786): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
#16 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(377): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#17 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(201): Drupal\Core\Render\Renderer->doRender(Array, false)
#18 /opt/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(241): Drupal\Core\Render\Renderer->render(Array, false)
#19 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(578): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#20 /opt/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(242): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#21 /opt/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(132): Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#22 /opt/drupal/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#23 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#24 /opt/drupal/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#25 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(163): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ViewEvent), 'kernel.view')
#26 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#27 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#34 /opt/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#35 /opt/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(717): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#36 /opt/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#37 {main}. (Exception)

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon 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

m4olivei created an issue. See original summary.

  • m4olivei committed 54373d8 on 8.x-1.x
    Issue #3229543 Fix hidden Drupal 9 deprecation
    
m4olivei’s picture

Status: Active » Patch (to be ported)

Fixed! Merged to 8.x-1.x.

m4olivei’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.