Odd map_meta_cap $args on post edit — sometimes integer, sometimes string

The map_meta_cap function handles context arguments generically – you can give it anything and it’ll happily pass it down the chain. It’s only particular capabilities like edit_post that expect the argument to be an integer, but even then it’s up to the caller to pass an appropriate value.

Here’s where you get your string/integer mashups – usually the caller will pass the ID straight from a WP_Post object, but it could be from anywhere – another database call, another object that has a reference to a post ID, hardcoded etc. In other words, lots of opportunities for a string to slip through.

You can try a debug_backtrace on your tests to find the culprits, but there are more important things in life to get on with – stick to your int type-casting and carry on coding 😉