getScheme() is not a method of Public stream wrapper

Created on 7 December 2023, 12 months ago

Problem/Motivation

I am seeing the following error when using redirection:

The website encountered an unexpected error. Please try again later.

Error: Call to undefined method Drupal\Core\StreamWrapper\PublicStream::getScheme() in Drupal\media_link_enhancements\Controller\MediaLinkEnhancementsController->download() (line 220 of modules/contrib/media_link_enhancements/src/Controller/MediaLinkEnhancementsController.php).
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
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: 181)
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: 53)
Asm89\Stack\Cors->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: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

In the media link configuration (admin/config/media/media_link_enhancements):
- disable direct linking
- enable redirection
- go and create a link to a media item that is configured for redirection
- click on the link

Proposed resolution

The getScheme() method actually belongs to the StreamWrapperManager service that is available. Looks like the method was attempting to be used on the wrapper directly (and with no parameter). So, change $wrapper->getScheme() to $this->streamWrapperManager->getScheme($uri).

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States tzura

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024