返回介绍

wp_should_upgrade_global_tables()

发布于 2017-09-11 12:56:18 字数 2638 浏览 1019 评论 0 收藏 0

wp_should_upgrade_global_tables()

Determine if global tables should be upgraded.


description

This function performs a series of checks to ensure the environment allows for the safe upgrading of global WordPress database tables. It is necessary because global tables will commonly grow to millions of rows on large installations, and the ability to control their upgrade routines can be critical to the operation of large networks.

In a future iteration, this function may use wp_is_large_network() to more- intelligently prevent global table upgrades. Until then, we make sure WordPress is on the main site of the main network, to avoid running queries more than once in multi-site or multi-network environments.


返回值

(bool) Whether to run the upgrade routines on global tables.


源代码

File: wp-admin/includes/upgrade.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 );
}

更新日志

Versiondescription
4.3.0Introduced.

相关函数

Uses

  • wp-admin/includes/upgrade.php: wp_should_upgrade_global_tables
  • wp-includes/functions.php: is_main_network()
  • wp-includes/functions.php: is_main_site()
  • wp-includes/plugin.php: apply_filters()

Used By

  • wp-admin/includes/upgrade.php: pre_schema_upgrade()
  • wp-admin/includes/upgrade.php: upgrade_network()
  • wp-admin/includes/upgrade.php: dbDelta()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文