fix for forgetMiddleware function 

forgetMiddleware function was checking an object against a (string) class name so it would never match and remove the middleware.
Merge pull request #5473 from fzahabian/4.2

fix for forgetMiddleware function