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

Handle invalid storage when getting storage root id #29210

Merged
merged 1 commit into from
Oct 19, 2017

Conversation

PVince81
Copy link
Contributor

Description

Whenever an invalid storage is present like a remote storage with invalid certificate, the mount point handling code will fail hard because the storage could not be instantiated.

Steps here: #28763 (comment)
Analysis here: #28763 (comment)

Related Issue

#28763

Motivation and Context

How Has This Been Tested?

See steps

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

return (int)$this->getStorage()->getCache()->getId('');
$storage = $this->getStorage();
if ($storage !== null && !$this->invalidStorage) {
return (int)$storage->getCache()->getId('');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test if cache is null???

@PVince81
Copy link
Contributor Author

@DeepDiver1975 I've adjusted it: now it also checks if the cache is null.

As a bonus, I also added unit tests and squashed.

$cache = $storage->getCache();

if ($cache === null) {
return -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worthy to provide different value to mark different errors, such as -1 = storage not found, -2 invalid = storage? Use constants?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not at this point... this method is only called in one location currently and doesn't care what the error is about

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fair enough.

Could you add the information in the PHPDoc? Otherwise -1 would be a valid storage id that wouldn't need special handling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now adjusted the PHPDoc and also the one from IMountPoint to mention the -1 value

@PVince81
Copy link
Contributor Author

stable10: #29278

@DeepDiver1975 DeepDiver1975 merged commit 5c51777 into master Oct 19, 2017
@DeepDiver1975 DeepDiver1975 deleted the handle-mount-invalidstorage branch October 19, 2017 18:16
@lock
Copy link

lock bot commented Aug 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants