From a1b991edb98c92f049045e69d38b873cafdcabd8 Mon Sep 17 00:00:00 2001 From: acsfer Date: Sat, 22 May 2021 13:44:24 +0200 Subject: [PATCH 1/5] Using empty file as ZipArchive is deprecated Fix #27064 --- lib/private/Archive/ZIP.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Archive/ZIP.php b/lib/private/Archive/ZIP.php index e058d4760218d..f48a6b206c969 100644 --- a/lib/private/Archive/ZIP.php +++ b/lib/private/Archive/ZIP.php @@ -47,7 +47,7 @@ class ZIP extends Archive { public function __construct($source) { $this->path = $source; $this->zip = new \ZipArchive(); - if ($this->zip->open($source, \ZipArchive::CREATE)) { + if ($this->zip->open($source, \ZipArchive::OVERWRITE)) { } else { \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, ILogger::WARN); } From e5026c973a58ddbad08ffe78c77bd3a55eb18d32 Mon Sep 17 00:00:00 2001 From: acsfer Date: Sat, 22 Jan 2022 23:13:14 +0100 Subject: [PATCH 2/5] Create if it's not there, else will overwrite --- lib/private/Archive/ZIP.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Archive/ZIP.php b/lib/private/Archive/ZIP.php index f48a6b206c969..0899ac969c3c3 100644 --- a/lib/private/Archive/ZIP.php +++ b/lib/private/Archive/ZIP.php @@ -47,7 +47,7 @@ class ZIP extends Archive { public function __construct($source) { $this->path = $source; $this->zip = new \ZipArchive(); - if ($this->zip->open($source, \ZipArchive::OVERWRITE)) { + if ($this->zip->open($source, (\ZipArchive::CREATE | \ZipArchive::OVERWRITE))) { } else { \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, ILogger::WARN); } From a1a7bfd89531bb9aab6681dcabb218d38750acda Mon Sep 17 00:00:00 2001 From: acsfer Date: Sun, 23 Jan 2022 15:39:21 +0100 Subject: [PATCH 3/5] Remove else condition --- lib/private/Archive/ZIP.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/private/Archive/ZIP.php b/lib/private/Archive/ZIP.php index 0899ac969c3c3..013c16bee3372 100644 --- a/lib/private/Archive/ZIP.php +++ b/lib/private/Archive/ZIP.php @@ -47,8 +47,7 @@ class ZIP extends Archive { public function __construct($source) { $this->path = $source; $this->zip = new \ZipArchive(); - if ($this->zip->open($source, (\ZipArchive::CREATE | \ZipArchive::OVERWRITE))) { - } else { + if (!$this->zip->open($source, ZipArchive::CREATE | ZipArchive::OVERWRITE)) { \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, ILogger::WARN); } } From 8f6aa4c6eb9aecf33b0f208b34cfe69f949c44b2 Mon Sep 17 00:00:00 2001 From: acsfer Date: Sun, 23 Jan 2022 15:57:37 +0100 Subject: [PATCH 4/5] Try to fix Psalm --- lib/private/Archive/ZIP.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Archive/ZIP.php b/lib/private/Archive/ZIP.php index 013c16bee3372..e6d66936f042a 100644 --- a/lib/private/Archive/ZIP.php +++ b/lib/private/Archive/ZIP.php @@ -46,7 +46,7 @@ class ZIP extends Archive { */ public function __construct($source) { $this->path = $source; - $this->zip = new \ZipArchive(); + $this->zip = new ZipArchive(); if (!$this->zip->open($source, ZipArchive::CREATE | ZipArchive::OVERWRITE)) { \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, ILogger::WARN); } From b750a909f051056e5b9aafc52ae03d6c9d6f09ba Mon Sep 17 00:00:00 2001 From: acsfer Date: Sun, 23 Jan 2022 16:28:19 +0100 Subject: [PATCH 5/5] Typo --- lib/private/Archive/ZIP.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/private/Archive/ZIP.php b/lib/private/Archive/ZIP.php index e6d66936f042a..e5cf1473bbf5f 100644 --- a/lib/private/Archive/ZIP.php +++ b/lib/private/Archive/ZIP.php @@ -46,8 +46,8 @@ class ZIP extends Archive { */ public function __construct($source) { $this->path = $source; - $this->zip = new ZipArchive(); - if (!$this->zip->open($source, ZipArchive::CREATE | ZipArchive::OVERWRITE)) { + $this->zip = new \ZipArchive(); + if (!$this->zip->open($source, \ZipArchive::CREATE | \ZipArchive::OVERWRITE)) { \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, ILogger::WARN); } }