From dbc1e9d57b102aa3f0c26a21b6aa1b7016bcf644 Mon Sep 17 00:00:00 2001
From: Thomas Hackl <hackl@data-quest.de>
Date: Tue, 18 Jun 2024 07:41:19 +0000
Subject: [PATCH] Resolve "Exception in OpenGraph::extract() bei null-String"

Closes #4319

Merge request studip/studip!3119
---
 lib/classes/OpenGraph.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/classes/OpenGraph.php b/lib/classes/OpenGraph.php
index fb0ac5cb151..845f5cb21fb 100644
--- a/lib/classes/OpenGraph.php
+++ b/lib/classes/OpenGraph.php
@@ -11,14 +11,14 @@ class OpenGraph
     /**
      * Extracts urls and their according open graph infos from a given string
      *
-     * @param string $string Text to extract urls and open graph infos from
+     * @param string|null $string Text to extract urls and open graph infos from
      * @return OpenGraphURLCollection containing the extracted urls
      */
-    public static function extract(string $string): OpenGraphURLCollection
+    public static function extract(?string $string): OpenGraphURLCollection
     {
         $collection = new OpenGraphURLCollection();
 
-        if (!Config::get()->OPENGRAPH_ENABLE) {
+        if (!Config::get()->OPENGRAPH_ENABLE || !$string) {
             return $collection;
         }
 
-- 
GitLab