Fix issues with searchByTag in shared storage

Fixes https://github.com/owncloud/core/issues/12938
See linked issue for testing steps.

Please review @dttpy @icewind1991 @LukasReschke @schiesbn