Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP7.4] Fix array access in FederatedShareProvider and Storage/DAV #37311

Merged
merged 2 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()]);
Expand Down
8 changes: 8 additions & 0 deletions changelog/unreleased/37311
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion lib/private/Files/Storage/DAV.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 . '/');
Expand Down