Problem/Motivation

When changing the order of link / string/ string_long types of fields on the manage display (maybe only in combination with Field Group order changes that messes things up a bit), Field Formatter type can get changed to "Soundcloud embed", resulting in the error shown below.

Proposed resolution

It should actually only be possible to choose that Field Formatter when the field type is a media field.

Remaining tasks

Create a patch and review.

Error message

Error: Call to undefined method Drupal\node\Entity\Node::getSource() in Drupal\media_entity_soundcloud\Plugin\Field\FieldFormatter\SoundcloudEmbedFormatter->viewElements() (line 111 of /var/www/html/web/modules/contrib/media_entity_soundcloud/src/Plugin/Field/FieldFormatter/SoundcloudEmbedFormatter.php)

#0 /var/www/html/web/core/lib/Drupal/Core/Field/FormatterBase.php(80): Drupal\media_entity_soundcloud\Plugin\Field\FieldFormatter\SoundcloudEmbedFormatter->viewElements(Object(Drupal\Core\Field\FieldItemList), 'en')
#1 /var/www/html/web/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php(263): Drupal\Core\Field\FormatterBase->view(Object(Drupal\Core\Field\FieldItemList), 'en')
#2 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(321): Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array)
#3 /var/www/html/web/core/modules/node/src/NodeViewBuilder.php(22): Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'popup')
#4 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(263): Drupal\node\NodeViewBuilder->buildComponents(Array, Array, Array, 'popup')
#5 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(220): Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array)
#6 [internal function]: Drupal\Core\Entity\EntityViewBuilder->build(Array)
#7 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(378): call_user_func(Array, Array)
#8 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, true)
#9 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(139): Drupal\Core\Render\Renderer->render(Array, true)
#10 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
#11 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(140): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#12 /var/www/html/web/modules/contrib/leaflet/leaflet_views/src/Controller/LeafletAjaxPopupController.php(85): Drupal\Core\Render\Renderer->renderRoot(Array)
#13 [internal function]: Drupal\leaflet_views\Controller\LeafletAjaxPopupController->popupBuild(Object(Drupal\node\Entity\Node), 'popup', 'en')
#14 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#15 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#16 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#17 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#18 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#19 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#20 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#29 {main}

Comments

heliogabal created an issue. See original summary.

sergiu stici’s picture

Status: Active » Needs review
StatusFileSize
new901 bytes

I made a patch. Please review.

Status: Needs review » Needs work
heliogabal’s picture

Status: Needs work » Reviewed & tested by the community

I tested the patch, applied cleanly and now I can't select the soundcloud embed field formatters for fields that are not media.

I can't really test for now if everything still works as it should with an actual soundcloud embed, as I don't use it.

But my initial issue is fixed.

Status: Reviewed & tested by the community » Needs work

  • jcisio committed 09d2ca6 on 8.x-2.x authored by Sergiu Stici
    Issue #3031830 by Sergiu Stici: Soundcloud embed Formatter should only...
jcisio’s picture

Status: Needs work » Fixed

Committed and pushed. Thank you.

Status: Fixed » Closed (fixed)

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