确定是否应升级全局表。
原型
wp_should_upgrade_global_tables()
描述
此函数执行一系列检查以确保环境允许安全升级全局WordPress数据库表。这是必要的,因为在大型安装中,全局表通常会增长到数百万行,并且控制其升级例程的能力对于大型网络的运行至关重要。
返回值
(bool)
是否在全局表上运行升级例程。
源文件
路径:wp-admin/includes/upgrade.php
<?php
...
function wp_should_upgrade_global_tables() {
// Return false early if explicitly not upgrading
if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
return false;
}
// Assume global tables should be upgraded
$should_upgrade = true;
// Set to false if not on main network (does not matter if not multi-network)
if ( ! is_main_network() ) {
$should_upgrade = false;
}
// Set to false if not on main site of current network (does not matter if not multi-site)
if ( ! is_main_site() ) {
$should_upgrade = false;
}
/**
* Filters if upgrade routines should be run on global tables.
*
* @param bool $should_upgrade Whether to run the upgrade routines on global tables.
*/
return apply_filters( 'wp_should_upgrade_global_tables', $should_upgrade );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_should_upgrade_global_tables/