From 40ea01d759ebd6cc3a11d3ae35da6cdfe424a628 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sun, 6 Oct 2013 15:45:09 +0000 Subject: [PATCH] Be as sure as possible that WordPress is not under version control when deciding if we should do automatic updates. see #22704. git-svn-id: https://develop.svn.wordpress.org/trunk@25700 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-upgrader.php | 31 +++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php index 51aa97cb54..df81f8ccd0 100644 --- a/src/wp-admin/includes/class-wp-upgrader.php +++ b/src/wp-admin/includes/class-wp-upgrader.php @@ -1488,18 +1488,27 @@ class WP_Automatic_Upgrader { * Check for GIT/SVN checkouts. */ static function is_vcs_checkout( $context ) { - $stop_dirs = array( - ABSPATH, - untrailingslashit( $context ), - ); - if ( ! file_exists( ABSPATH . '/wp-config.php' ) ) // wp-config.php up one folder in a deployment situation - $stop_dirs[] = dirname( ABSPATH ); + $context_dirs = array( untrailingslashit( $context ) ); + if ( $context !== ABSPATH ) + $context_dirs[] = untrailingslashit( ABSPATH ); - $checkout = false; - foreach ( array_unique( $stop_dirs ) as $dir ) { - if ( file_exists( $dir . '/.svn' ) || file_exists( $dir . '/.git' ) || file_exists( $dir . '/.hg' ) || file_exists( $dir . '/.bzr' ) ) { - $checkout = true; - break; + $vcs_dirs = array( '.svn', '.git', '.hg', '.bzr' ); + $check_dirs = array(); + + foreach ( $context_dirs as $context_dir ) { + // Walk up from $context_dir to the root. + do { + $check_dirs[] = $context_dir; + } while ( $context_dir != dirname( $context_dir ) && $context_dir = dirname( $context_dir ) ); + } + + $check_dirs = array_unique( $check_dirs ); + + // Search all directories we've found for evidence of version control. + foreach ( $vcs_dirs as $vcs_dir ) { + foreach ( $check_dirs as $check_dir ) { + if ( $checkout = is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) + break 2; } } return apply_filters( 'auto_upgrade_is_vcs_checkout', $checkout, $context );