From 5fbdd1376a144be6991b0f8b7502521e647e6114 Mon Sep 17 00:00:00 2001 From: nathangray Date: Fri, 21 May 2021 10:43:09 -0600 Subject: [PATCH] Fix PHP warnings for PHP 8 compatability --- api/src/Contacts.php | 2 +- api/src/Etemplate/Widget/File.php | 7 ++++--- api/src/Sharing.php | 16 +++++++++------- api/tests/Vfs/SharingBase.php | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/api/src/Contacts.php b/api/src/Contacts.php index f3835f5749..09acb061ad 100755 --- a/api/src/Contacts.php +++ b/api/src/Contacts.php @@ -2744,7 +2744,7 @@ class Contacts extends Contacts\Storage header('Content-length: '.bytes($contact['jpegphoto'])); echo $contact['jpegphoto']; } - else + elseif ($url) { header('Content-length: '.$size); readfile($url); diff --git a/api/src/Etemplate/Widget/File.php b/api/src/Etemplate/Widget/File.php index 7946d1ef92..06caef931a 100644 --- a/api/src/Etemplate/Widget/File.php +++ b/api/src/Etemplate/Widget/File.php @@ -204,6 +204,7 @@ class File extends Etemplate\Widget ); } } + return true; } /** @@ -247,7 +248,7 @@ class File extends Etemplate\Widget } fclose($fp); } else { - _log('cannot create the destination file'); + error_log(__METHOD__ . ' cannot create the destination file "'.$new_file.'"'); return false; } @@ -307,7 +308,7 @@ class File extends Etemplate\Widget if (!$this->is_readonly($cname, $form_name)) { - $value = $value_in = self::get_array($content, $form_name); + $value = self::get_array($content, $form_name); $valid =& self::get_array($validated, $form_name, true); if(!is_array($value)) $value = array(); @@ -317,7 +318,7 @@ class File extends Etemplate\Widget foreach($value as $tmp => $file) { - if(!$file) continue; + if(!$file || !is_array($file)) continue; if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) { $path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmp; diff --git a/api/src/Sharing.php b/api/src/Sharing.php index 99d17efa2f..a71002aae5 100644 --- a/api/src/Sharing.php +++ b/api/src/Sharing.php @@ -348,9 +348,11 @@ class Sharing /** * Get the namespaced class for the given share * - * @param string $share + * @param array $share + * @return string + * @throws Exception */ - protected static function get_share_class($share) + protected static function get_share_class(array $share) { try { @@ -698,7 +700,7 @@ class Sharing * @param String $path * @param boolean $writable Allow editing the shared entry / folder / file * @param boolean $files For sharing an application entry, allow access to the linked files - * @param $extra Additional extra parameters + * @param array $extra Additional extra parameters */ public static function ajax_create($action, $path, $writable = false, $files = false, $extra = array()) { @@ -721,7 +723,7 @@ class Sharing ); // Store share in session so Merge can find this one and not create a read-only one - \EGroupware\Api\Cache::setSession(__CLASS__, $path, $share); + Cache::setSession(__CLASS__, $path, $share); $arr = array( 'action' => $action, 'writable' => $writable, @@ -745,7 +747,7 @@ class Sharing /** * Api\Storage\Base instance for egw_sharing table * - * @var Api\Storage\Base + * @var Storage\Base */ protected static $so; @@ -884,7 +886,7 @@ class Sharing * Check that the share path is still valid, and if not, delete it. * This should be overridden. * - * @param Array share + * @param array share * * @return boolean Is the share still valid */ @@ -913,7 +915,7 @@ class Sharing * * @param string $path * - * @throws WrongParameter if you try to share a path that needs a password + * @throws Exception\WrongParameter if you try to share a path that needs a password */ public static function path_needs_password($path) { diff --git a/api/tests/Vfs/SharingBase.php b/api/tests/Vfs/SharingBase.php index 99803ed946..369808f44e 100644 --- a/api/tests/Vfs/SharingBase.php +++ b/api/tests/Vfs/SharingBase.php @@ -746,7 +746,7 @@ class TestSharing extends Api\Vfs\Sharing { return $sessionid; } - public static function get_share_class($share) + public static function get_share_class(array $share) { return __CLASS__; } @@ -773,7 +773,7 @@ if(!class_exists('TestHiddenSharing')) return $sessionid; } - public static function get_share_class($share) + public static function get_share_class(array $share) { return __CLASS__; }