aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2021-10-25 16:41:15 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2021-11-23 09:29:01 +0100
commit5cd5245ca8b7b37156476ad128131ac5abc3891c (patch)
tree639f8240332f03dc7fe18ecbf8f6ac88f832bafe /apps
parent5a20e20e9ea9adbabe73afa5d2096575de5503ea (diff)
downloadnextcloud-server-5cd5245ca8b7b37156476ad128131ac5abc3891c.tar.gz
nextcloud-server-5cd5245ca8b7b37156476ad128131ac5abc3891c.zip
Fix dav application tests and code for PHP 8.1
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php2
-rw-r--r--apps/dav/lib/Connector/Sabre/Auth.php2
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesReportPlugin.php2
-rw-r--r--apps/dav/lib/Upload/AssemblyStream.php2
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php3
5 files changed, 7 insertions, 4 deletions
diff --git a/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php b/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php
index a71725af121..6c3600fa5eb 100644
--- a/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php
@@ -62,7 +62,7 @@ class AnonymousOptionsPlugin extends ServerPlugin {
* @return bool
*/
public function handleAnonymousOptions(RequestInterface $request, ResponseInterface $response) {
- $isOffice = preg_match('/Microsoft Office/i', $request->getHeader('User-Agent'));
+ $isOffice = preg_match('/Microsoft Office/i', $request->getHeader('User-Agent') ?? '');
$emptyAuth = $request->getHeader('Authorization') === null
|| $request->getHeader('Authorization') === ''
|| trim($request->getHeader('Authorization')) === 'Bearer';
diff --git a/apps/dav/lib/Connector/Sabre/Auth.php b/apps/dav/lib/Connector/Sabre/Auth.php
index 30a27f672dd..71e833809ac 100644
--- a/apps/dav/lib/Connector/Sabre/Auth.php
+++ b/apps/dav/lib/Connector/Sabre/Auth.php
@@ -242,7 +242,7 @@ class Auth extends AbstractBasic {
}
}
- if (!$this->userSession->isLoggedIn() && in_array('XMLHttpRequest', explode(',', $request->getHeader('X-Requested-With')))) {
+ if (!$this->userSession->isLoggedIn() && in_array('XMLHttpRequest', explode(',', $request->getHeader('X-Requested-With') ?? ''))) {
// do not re-authenticate over ajax, use dummy auth name to prevent browser popup
$response->addHeader('WWW-Authenticate','DummyBasic realm="' . $this->realm . '"');
$response->setStatus(401);
diff --git a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
index 9524fe59746..4876e9ad8f3 100644
--- a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
@@ -241,7 +241,7 @@ class FilesReportPlugin extends ServerPlugin {
*
* @return string files base uri
*/
- private function getFilesBaseUri($uri, $subPath) {
+ private function getFilesBaseUri(string $uri, string $subPath): string {
$uri = trim($uri, '/');
$subPath = trim($subPath, '/');
if (empty($subPath)) {
diff --git a/apps/dav/lib/Upload/AssemblyStream.php b/apps/dav/lib/Upload/AssemblyStream.php
index 4d8f98a4332..ef6d39974c0 100644
--- a/apps/dav/lib/Upload/AssemblyStream.php
+++ b/apps/dav/lib/Upload/AssemblyStream.php
@@ -277,7 +277,7 @@ class AssemblyStream implements \Icewind\Streams\File {
]);
stream_wrapper_register('assembly', self::class);
try {
- $wrapped = fopen('assembly://', 'r', null, $context);
+ $wrapped = fopen('assembly://', 'r', false, $context);
} catch (\BadMethodCallException $e) {
stream_wrapper_unregister('assembly');
throw $e;
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
index 1d1329bbb3c..f73434b33b6 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
@@ -229,6 +229,9 @@ class FilesReportPluginTest extends \Test\TestCase {
$reportTargetNode = $this->getMockBuilder(Directory::class)
->disableOriginalConstructor()
->getMock();
+ $reportTargetNode->expects($this->any())
+ ->method('getPath')
+ ->willReturn('');
$response = $this->getMockBuilder(ResponseInterface::class)
->disableOriginalConstructor()