Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.1 compatibility #282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions wwwroot/inc/caching.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function HTTPDateToUnixTime ($string)
$formats['asctime'] = '/^(Sun|Mon|Tue|Wed|Thu|Fri|Sat) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{2}| \d{1}) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/';

$matches = array();
if (preg_match ($formats['rfc1123'], $string, $matches))
if (preg_match ($formats['rfc1123'], $string ?? "", $matches))
{
$hours = $matches[5];
$minutes = $matches[6];
Expand All @@ -76,7 +76,7 @@ function HTTPDateToUnixTime ($string)
$day = $matches[2];
$year = $matches[4];
}
elseif (preg_match ($formats['rfc850'], $string, $matches))
elseif (preg_match ($formats['rfc850'], $string ?? "", $matches))
{
$hours = $matches[5];
$minutes = $matches[6];
Expand All @@ -85,7 +85,7 @@ function HTTPDateToUnixTime ($string)
$day = $matches[2];
$year = $matches[4];
}
elseif (preg_match ($formats['asctime'], $string, $matches))
elseif (preg_match ($formats['asctime'], $string ?? "", $matches))
{
$hours = $matches[4];
$minutes = $matches[5];
Expand Down
6 changes: 3 additions & 3 deletions wwwroot/inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions wwwroot/inc/interface-lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1210,14 +1210,14 @@ function stringForTD ($string, $maxlen = 30)
function stringForTextInputValue ($string, $maxlen = 30)
{
if ($maxlen != 0)
$string = mb_substr ($string, 0, $maxlen);
$string = mb_substr ($string ?? "", 0, $maxlen);
return htmlspecialchars ($string, ENT_QUOTES, 'UTF-8');
}

// "<TEXTAREA>%s</TEXTAREA>"
function stringForTextarea ($string)
{
return htmlspecialchars ($string, ENT_QUOTES, 'UTF-8');
return htmlspecialchars ($string ?? "", ENT_QUOTES, 'UTF-8');
}

// <OPTION>%s</OPTION>
Expand Down
2 changes: 1 addition & 1 deletion wwwroot/inc/popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function findSparePorts ($port_info, $filter)
}
$rows_by_pn = array();
}
$prev_object_id = $row['object_id'];
$prev_object_id = $row['object_id'] ?? "";
if ($row)
$rows_by_pn[$row['name']][] = $row;
else
Expand Down
2 changes: 1 addition & 1 deletion wwwroot/inc/solutions.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ function proxyStaticURI ($URI)
if
(
! preg_match (RE_STATIC_URI, $URI, $matches) ||
! array_key_exists (strtolower ($matches[1]), $content_type)
! array_key_exists (strtolower ($matches[1] ?? ""), $content_type)
)
printStatic404();
global $local_staticdir, $racktables_staticdir;
Expand Down