今日の朝、このサイトがWordPress5.8にアップデートされた。
WordPress5.8のアップデートはローカル環境でテストしてから行いたかったのになんで?
本番環境では、自動アップデートがONになっていた。納得。
ローカル環境をみると、アップデートされてない。
ローカル環境で見ていた時、手動アップデートの表示なってるから、自動更新されないものだと思い込んでいた。
ソースやデータベースも同じはずなのに。なぜ?

ローカル環境では、なんでアップデートされなかったのか調べてみると、
「サイトはバージョン管理されているようです。自動更新は無効化されています。」と表示されていた。

ソースを調べてみると、ここで表示される表示になっていた。
<p class="auto-update-status">
<?php
if ( $updater->is_vcs_checkout( ABSPATH ) ) {
_e( 'This site appears to be under version control. Automatic updates are disabled.' );
} elseif ( $upgrade_major ) {
_e( 'This site is automatically kept up to date with each new version of WordPress.' );
if ( $can_set_update_option ) {
echo '<br>';
printf(
'<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-disable">%s</a>',
wp_nonce_url( add_query_arg( 'value', 'disable', $action_url ), 'core-major-auto-updates-nonce' ),
__( 'Switch to automatic updates for maintenance and security releases only.' )
);
}
} elseif ( $upgrade_minor ) {
_e( 'This site is automatically kept up to date with maintenance and security releases of WordPress only.' );
if ( $can_set_update_option ) {
echo '<br>';
printf(
'<a href="%s" class="core-auto-update-settings-link core-auto-update-settings-link-enable">%s</a>',
wp_nonce_url( add_query_arg( 'value', 'enable', $action_url ), 'core-major-auto-updates-nonce' ),
__( 'Enable automatic updates for all new versions of WordPress.' )
);
}
} else {
_e( 'This site will not receive automatic updates for new versions of WordPress.' );
}
?>
</p>
is_vcs_checkout関数をみると、.gitディレクトリをチェックして、.gitあればバージョン管理されていると判定されるよう。
public function is_vcs_checkout( $context ) {
$context_dirs = array( untrailingslashit( $context ) );
if ( ABSPATH !== $context ) {
$context_dirs[] = untrailingslashit( ABSPATH );
}
$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;
// Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here.
if ( dirname( $context_dir ) === $context_dir ) {
break;
}
// Continue one level at a time.
} while ( $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 ) {
$checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" );
if ( $checkout ) {
break 2;
}
}
}
/**
* Filters whether the automatic updater should consider a filesystem
* location to be potentially managed by a version control system.
*
* @since 3.7.0
*
* @param bool $checkout Whether a VCS checkout was discovered at `$context`
* or ABSPATH, or anywhere higher.
* @param string $context The filesystem context (a path) against which
* filesystem status should be checked.
*/
return apply_filters( 'automatic_updates_is_vcs_checkout', $checkout, $context );
}
バージョン管理されているサイトは自動更新は無効。
確かにgitで管理しているので、そうして欲しい。
WordPress気が利いている。
とりあえず、このサイトはテーマ、プラグインも含め手動でアップデートしたいので。wp-config.phpにAUTOMATIC_UPDATER_DISABLED
を追記して自動アップデートを無効化した。
/**
* 自動アップデート停止
*/
define( 'AUTOMATIC_UPDATER_DISABLED', true );