fix the middleware registration process in the container
use references for middleware to fix problems on 5.3
Merge pull request #8156 from owncloud/fix-middleware-container

fix the middleware registration process in the container