Backport overwrite from 3.0 into 2.6

Docs for https://github.com/cakephp/cakephp/pull/3412