Calling setup_postdata() causes “Call to undefined function get_userdata()” error?

Your problem is that you’re adding a return new CLASSNAME( $data ); at the end of a file(?).

You need to make that call inside a function and add the fn callback to a hook like this:

// THIS IS ONLY AN EXAMPLE!
function wpse46288_call_the_funk()
{
    return new CLASSNAME( $data );
}
add_action( 'init', 'wpse46288_call_the_funk' );