It’s a bit simpler to let WordPress handle generating the permastruct when you register your post type. I also recommend against using global variables, there are API functions for most of what you need to accomplish with the rewrite class.
function magazine_issues_rewrite() {
add_rewrite_tag( '%issuenumber%', '([^&]+)' );
add_rewrite_tag( '%issueyear%', '([^&]+)' );
// post type registration, other args removed for clarity
$args = array(
'rewrite' => array( 'slug' => 'issue/%issueyear%/%issuenumber%' ),
);
register_post_type( 'issue', $args );
}
add_action( 'init', 'magazine_issues_rewrite' );
I’m not sure whether or not that will fix your problem, I haven’t tested your full code.