move common code into a function
Merge branch 'master' of git.php.net:php-src