From 8096807c6dc74ca39dc9f812570980c6da426f5b Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 12 Feb 2022 23:35:05 +1300 Subject: [PATCH] Fixes for warnings in PHP 8.1 --- htdocs/always.php | 4 +++- inc/CalDAVRequest.php | 10 +++++++--- inc/RRule.php | 4 ++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/always.php b/htdocs/always.php index 63be3b0d..984cc403 100644 --- a/htdocs/always.php +++ b/htdocs/always.php @@ -45,7 +45,9 @@ function clean_get() { if(isset($_POST)) array_walk($_POST, 'filter_post'); $_GET = clean_get(); $_SERVER['REQUEST_URI'] = str_replace("&", "&", htmlspecialchars($_SERVER['REQUEST_URI'])); -$_SERVER['HTTP_REFERER'] = htmlspecialchars(@$_SERVER['HTTP_REFERER']); +if (isset($_SERVER['HTTP_REFERER'])) { + $_SERVER['HTTP_REFERER'] = htmlspecialchars(@$_SERVER['HTTP_REFERER']); +} diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index f395671c..6670e1b8 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -217,9 +217,13 @@ class CalDAVRequest $_SERVER['REQUEST_METHOD'] = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']; } $this->method = $_SERVER['REQUEST_METHOD']; - $this->content_type = (isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : null); - if ( preg_match( '{^(\S+/\S+?)\s*(;.*)?$}', $this->content_type, $matches ) ) { - $this->content_type = $matches[1]; + if (isset($_SERVER['CONTENT_TYPE'])) { + $this->content_type = $_SERVER['CONTENT_TYPE']; + if ( preg_match( '{^(\S+/\S+?)\s*(;.*)?$}', $this->content_type, $matches ) ) { + $this->content_type = $matches[1]; + } + } else { + $this->content_type = null; } if ( strlen($c->raw_post) > 0 ) { if ( $this->method == 'PROPFIND' || $this->method == 'REPORT' || $this->method == 'PROPPATCH' || $this->method == 'BIND' || $this->method == 'MKTICKET' || $this->method == 'ACL' ) { diff --git a/inc/RRule.php b/inc/RRule.php index cd8aeb1f..72854d75 100644 --- a/inc/RRule.php +++ b/inc/RRule.php @@ -354,6 +354,7 @@ class RepeatRuleDateTime extends DateTime { } + #[\ReturnTypeWillChange] public function modify( $interval ) { // print ">>$interval<<\n"; if ( preg_match('{^(-)?P(([0-9-]+)W)?(([0-9-]+)D)?T?(([0-9-]+)H)?(([0-9-]+)M)?(([0-9-]+)S)?$}', $interval, $matches) ) { @@ -444,6 +445,7 @@ class RepeatRuleDateTime extends DateTime { } + #[\ReturnTypeWillChange] public function setTimeZone( $tz ) { if ( is_string($tz) ) { $tz = new RepeatRuleTimeZone($tz); @@ -454,6 +456,7 @@ class RepeatRuleDateTime extends DateTime { } + #[\ReturnTypeWillChange] public function getTimeZone() { return $this->tzid; } @@ -482,6 +485,7 @@ class RepeatRuleDateTime extends DateTime { } + #[\ReturnTypeWillChange] function setDate( $year=null, $month=null, $day=null ) { if ( !isset($year) ) $year = parent::format('Y'); if ( !isset($month) ) $month = parent::format('m');