PHP error on embedding Youtube Shorts

Created on 5 October 2023, about 1 year ago
Updated 13 September 2024, 3 months ago

Problem/Motivation

When embedding a Youtube Shorts or Playlist video in a media and then placing that media onto a page, visiting that page results in a PHP error:

Deprecated function: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in Drupal\oembed_lazyload_youtube\Plugin\oembed_lazyload\ProviderEnhancer\YoutubeEnhancer->getEmbedCode() (line 69 of /code/web/modules/contrib/oembed_lazyload/modules/oembed_lazyload_youtube/src/Plugin/oembed_lazyload/ProviderEnhancer/YoutubeEnhancer.php)

Steps to reproduce

  • Add any Youtube Shorts as a media item
  • Embed that media item onto a node
  • Visit the node
  • Notice the error message in the log messages

Proposed resolution

  • Add additional if statements to YoutubeEnhancer.php to handle logic for all oembed provider endpoint schemes (https://oembed.com/providers.json)
  • Update automated tests (YoutubeEnhancerTest.php)
🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇦🇺Australia T.Barker

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

Comments & Activities

Production build 0.71.5 2024