port of issue #2771 to 0-6-stable