Just had this myself when refactoring a plugin I’m writing.
I moved the get_current_user_id out of a method into the constructor of my plugin object and it suddenly started to return 0.
Looks like when the plugin is instantiated the get_current_user_id method doesn’t exist yet (i.e. not loaded by WordPress yet) so it returns 0.
/**
* Get the current user's ID
*
* @since MU
*
* @return int The current user's ID
*/
function get_current_user_id() {
if ( ! function_exists( 'wp_get_current_user' ) )
return 0;
$user = wp_get_current_user();
return ( isset( $user->ID ) ? (int) $user->ID : 0 );
}
I’ll bet that’s what is happening here and that 4.2 has refactored when core functions are loaded.