diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index a00148d90670..1c4242b20915 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -240,7 +240,7 @@ protected function createFederatedShare(IShare $share) { $ownerAddress = $this->addressHandler->getLocalUserFederatedAddress($owner); $sharedWith = $share->getSharedWith(); $shareWithAddress = new Address($sharedWith); - $status = $this->notifications->sendRemoteShare( + $result = $this->notifications->sendRemoteShare( $shareWithAddress, $ownerAddress, $sharedByAddress, @@ -252,8 +252,16 @@ protected function createFederatedShare(IShare $share) { /* Check for failure or null return from sending and pick up an error message * if there is one coming from the remote server, otherwise use a generic one. */ - if (!$status || $status['ocs']['meta']['status'] === 'failure') { - $msg = $status['ocs']['meta']['message'] ?? false; + if (\is_bool($result)) { + $status = $result; + } elseif (isset($result['ocs']['meta']['status'])) { + $status = $result['ocs']['meta']['status']; + } else { + $status = false; + } + + if ($status === false) { + $msg = $result['ocs']['meta']['message'] ?? false; if (!$msg) { $message_t = $this->l->t('Sharing %s failed, could not find %s, maybe the server is currently unreachable.', [$share->getNode()->getName(), $share->getSharedWith()]); diff --git a/changelog/unreleased/37311 b/changelog/unreleased/37311 new file mode 100644 index 000000000000..ed9b6dcb58a6 --- /dev/null +++ b/changelog/unreleased/37311 @@ -0,0 +1,8 @@ +Bugfix: Rewrite code to fix some notices under PHP 7.4 + +Fixed "Trying to access array offset on value of type" notices in +OC\Files\Storage\DAV and OCA\FederatedFileSharing\FederatedShareProvider +under PHP 7.4. + +https://github.com/owncloud/core/pull/37311 +https://github.com/owncloud/core/issues/37303 diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index 61650b5cc0d2..cda3759626c5 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -684,7 +684,7 @@ private function simpleResponse($method, $path, $body, $expected) { // client request is in \OC\HTTP\Client /* @phan-suppress-next-line PhanUndeclaredMethod */ $response = $this->client->request($method, $this->encodePath($path), $body); - return $response['statusCode'] == $expected; + return isset($response['statusCode']) && $response['statusCode'] == $expected; } catch (ClientHttpException $e) { if ($e->getHttpStatus() === Http::STATUS_NOT_FOUND && $method === 'DELETE') { $this->statCache->clear($path . '/');