PHP笔记网

革命尚未成功,同志仍须努力下载JDK17

作者:Albert.Wen  添加时间:2023-05-10 12:27:36  修改时间:2024-10-27 07:35:47  分类:05.前端/Vue/Node.js  编辑

如果我们的服务器在国内,那么在后台更新WordPress的插件,主题的时候,难免碰到过“Briefly unavailable for scheduled maintenance. Check back in a minute.”的问题。

这是因为我们的服务器和WordPress服务器的连接速度太慢,导致程序本身认为服务器可能出了问题,强制进入维护(maintenance)时间,让服务器休息一会。

解决方案:

方式一:到网站根目录下,直接删除.maintenance文件

方式二:修改PHP代码,彻底去掉维护模式

找到文件:/wp-includes/load.php

/**
 * Check if maintenance mode is enabled.
 *
 * Checks for a file in the WordPress root directory named ".maintenance".
 * This file will contain the variable $upgrading, set to the time the file
 * was created. If the file was created less than 10 minutes ago, WordPress
 * is in maintenance mode.
 *
 * @since 5.5.0
 *
 * @global int $upgrading The Unix timestamp marking when upgrading WordPress began.
 *
 * @return bool True if maintenance mode is enabled, false otherwise.
 */
function wp_is_maintenance_mode() {
	global $upgrading;
    
	//【彻底关闭 维护模式】直接返回 false
	return false;
	
	if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) {
		return false;
	}

	require ABSPATH . '.maintenance';
	// If the $upgrading timestamp is older than 10 minutes, consider maintenance over.
	if ( ( time() - $upgrading ) >= 10 * MINUTE_IN_SECONDS ) {
		return false;
	}

	/**
	 * Filters whether to enable maintenance mode.
	 *
	 * This filter runs before it can be used by plugins. It is designed for
	 * non-web runtimes. If this filter returns true, maintenance mode will be
	 * active and the request will end. If false, the request will be allowed to
	 * continue processing even if maintenance mode should be active.
	 *
	 * @since 4.6.0
	 *
	 * @param bool $enable_checks Whether to enable maintenance mode. Default true.
	 * @param int  $upgrading     The timestamp set in the .maintenance file.
	 */
	if ( ! apply_filters( 'enable_maintenance_mode', true, $upgrading ) ) {
		return false;
	}

	return true;
}