Fixes #3634

Fixes https://github.com/cakephp/cakephp/issues/3634