Why is add_rewrite_endpoint incompatible with /%category%/%postname%/ permalink structure?

Why doesn’t it work? I’m not sure. That particular pattern is the same as a parent/child page request, WordPress has to do some extra queries to determine if a post exists by that name, or if it’s a page. Why this breaks when you add an endpoint, I haven’t delved into the code to determine.

How can you make it work? It appears that if you don’t use the EP_ALL mask and instead use the OR operator with all the individual masks, it will build the rules in such a way where those endpoints will correctly resolve.

For example:

function wpa_myvar_endpoint(){
    add_rewrite_endpoint( 'myvar', EP_PERMALINK | EP_PAGES );
}
add_action( 'init', 'wpa_myvar_endpoint' );