Merge the should_auto_update() and can_auto_update() methods. see #22704.

git-svn-id: https://develop.svn.wordpress.org/trunk@25815 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-10-16 19:34:05 +00:00
parent f8bd337fdb
commit 977ca48a58
1 changed files with 9 additions and 11 deletions

View File

@ -1601,10 +1601,15 @@ class WP_Automatic_Upgrader {
}
/**
* Tests to see if we should upgrade a specific item, does not test to see if we CAN update the item.
* Tests to see if we can and should upgrade a specific item.
*/
static function should_auto_update( $type, $item, $context ) {
// Checks to see if WP_Filesystem is set up to allow unattended upgrades.
$skin = new Automatic_Upgrader_Skin;
if ( ! $skin->request_filesystem_credentials( false, $context ) )
return false;
if ( self::upgrader_disabled() )
return false;
@ -1631,7 +1636,7 @@ class WP_Automatic_Upgrader {
if ( ! apply_filters( 'auto_upgrade_' . $type, $upgrade, $item ) )
return false;
// If it's a core update, are we actually compatible with it's requirements?
// If it's a core update, are we actually compatible with its requirements?
if ( 'core' == $type ) {
global $wpdb;
@ -1648,13 +1653,6 @@ class WP_Automatic_Upgrader {
return true;
}
// Checks to see if WP_Filesystem is setup to allow unattended upgrades
static function can_auto_update( $context, $skin = false ) {
if ( ! $skin )
$skin = new Automatic_Upgrader_Skin();
return (bool) $skin->request_filesystem_credentials( false, $context );
}
static function upgrade( $type, $item ) {
$skin = new Automatic_Upgrader_Skin();
@ -1680,8 +1678,8 @@ class WP_Automatic_Upgrader {
break;
}
// Determine if we can perform this upgrade or not
if ( ! self::should_auto_update( $type, $item, $context ) || ! self::can_auto_update( $context, $skin ) )
// Determine whether we can and should perform this upgrade.
if ( ! self::should_auto_update( $type, $item, $context ) )
return false;
switch ( $type ) {