when ever you expect something to be an array, it’s good practice to check to see if it is first before proceeding. so the new code might read like this:
if(is_null($post_ratings_data)) {
$post_ratings_data = get_post_custom($post_id);
if ( is_array( $post_ratings_data['ratings_users'] ) ) {
$post_ratings_users = intval($post_ratings_data['ratings_users'][0]);
$post_ratings_score = intval($post_ratings_data['ratings_score'][0]);
$post_ratings_average = floatval($post_ratings_data['ratings_average'][0]);
}
}