Fix warnings from FileEngine on shutdown
Fix warnings from FileEngine on shutdown

Check if the current file is valid before re-using it. This fixes
warnings emitted during process shutdown when DboSource is persisting
the method cache.

Forward port fix for #13085 to 3.x

ndm2/cakephp,cakephp/cakephp,cakephp/cakephp,dakota/cakephp,cakephp/cakephp,dakota/cakephp,mvdriel/cakephp,ndm2/cakephp,ADmad/cakephp,mvdriel/cakephp,ndm2/cakephp,dakota/cakephp,mvdriel/cakephp,ndm2/cakephp,cakephp/cakephp,mvdriel/cakephp,CakeDC/cakephp,CakeDC/cakephp,ADmad/cakephp,ADmad/cakephp,CakeDC/cakephp,ADmad/cakephp,CakeDC/cakephp,dakota/cakephp