Missing validation for the existence of youtube_get_video_id() function

Created on 9 June 2025, about 2 months ago

Problem/Motivation

The code does not validate whether the function `youtube_get_video_id()` is available before using it. This can cause fatal errors if the function is called but is not defined at runtime.

Steps to reproduce

  1. Install and enable the `lite_youtube` module.
  2. Ensure the `youtube` module is a required dependency in the `.info.yml`.
  3. Manually cause the `youtube_get_video_id()` function to be undefined (e.g., by modifying or breaking the `youtube` module).
  4. Access a page rendering a YouTube field with the `lite_youtube` formatter.
  5. Observe a fatal error due to the missing function.

Proposed resolution

Add a runtime check using `function_exists('youtube_get_video_id')` before calling the function. If the function is missing, log a critical error explaining the issue and skip rendering the affected item to prevent fatal errors.

Remaining tasks

  • Implement the function existence check in the `LiteYoutubeFormatter` class.
  • Add logging for missing function cases.
  • Test fallback behavior when the function is missing.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΎUruguay apereira23

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