From 118269b607bd957fa27d0296823d7e435e6900b9 Mon Sep 17 00:00:00 2001
From: Virsacer <virsacer@online.de>
Date: Sat, 10 Dec 2022 21:02:49 +0100
Subject: [PATCH] PHP 8.1 compatibility (fixes multiple deprecation messages
 and broken images)

---
 wwwroot/inc/caching.php       | 6 +++---
 wwwroot/inc/functions.php     | 6 +++---
 wwwroot/inc/interface-lib.php | 4 ++--
 wwwroot/inc/popup.php         | 2 +-
 wwwroot/inc/solutions.php     | 2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)

Index: wwwroot/inc/functions.php
--- wwwroot/inc/functions.php.orig
+++ wwwroot/inc/functions.php
@@ -1216,7 +1216,7 @@ function findAllEndpoints ($object_id, $fallback = '')
 // $record['href'] is set to URL if it is specified in the input value
 function parseWikiLink (&$record)
 {
-	if (! preg_match ('/^\[\[(.+)\]\]$/', $record['value'], $matches))
+	if (! preg_match ('/^\[\[(.+)\]\]$/', $record['value'] ?? "", $matches))
 		$record['o_value'] = $record['value'];
 	else
 	{
@@ -1233,7 +1233,7 @@ function execGMarker ($line)
 {
 	return preg_replace ('/^.+%GSKIP%/', '',
 		preg_replace ('/^(.+)%GPASS%/', '\\1 ',
-			preg_replace ('/%L\d+,\d+(H|V|)%/', '', $line)));
+			preg_replace ('/%L\d+,\d+(H|V|)%/', '', $line ?? "")));
 }
 
 // extract the layout information from the %L...% marker in the dictionary info
@@ -1402,7 +1402,7 @@ function parseAutoPortsConfig ($schema)
 {
 	$ret = array();
 
-	foreach (explode ('+', $schema) as $product)
+	foreach (explode ('+', $schema ?? "") as $product)
 	{
 		$tmp = explode ('*', $product);
 		if (count ($tmp) > 4 || count ($tmp) < 3)
