prevent PHP errors and enhance logging
fix return documentation
Merge pull request #10098 from owncloud/fix-10094-master

prevent PHP errors and enhance logging