Backport of https://github.com/owncloud/core/pull/7609

Backport of https://github.com/owncloud/core/pull/7609

@karlitschek @ser72 @MTRichards