From ce3f43c10f3b734f99084e5c5db3361d3d12b1b8 Mon Sep 17 00:00:00 2001 From: Yahnis Elsts Date: Tue, 7 Apr 2020 15:21:40 +0300 Subject: [PATCH] Don't change "tested":"x.y" to "tested":"x.y.999" when x.y already matches the current WordPress release. See #356 --- Puc/v4p9/UpdateChecker.php | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/Puc/v4p9/UpdateChecker.php b/Puc/v4p9/UpdateChecker.php index 2172b1f..db3e926 100644 --- a/Puc/v4p9/UpdateChecker.php +++ b/Puc/v4p9/UpdateChecker.php @@ -357,26 +357,39 @@ if ( !class_exists('Puc_v4p9_UpdateChecker', false) ): $wpVersion = $GLOBALS['wp_version']; - if ( function_exists('get_preferred_from_update_core') ) { - $coreUpdate = get_preferred_from_update_core(); - if ( isset($coreUpdate->current) && version_compare($coreUpdate->current, $wpVersion, '>') ) { - $actualWpVersions[] = $coreUpdate->current; + if ( function_exists('get_core_updates') ) { + $coreUpdates = get_core_updates(); + if ( is_array($coreUpdates) ) { + foreach ($coreUpdates as $coreUpdate) { + if ( isset($coreUpdate->current) ) { + $actualWpVersions[] = $coreUpdate->current; + } + } } } $actualWpVersions[] = $wpVersion; - $actualWpPatchNumber = "999"; + $actualWpPatchNumber = null; foreach ($actualWpVersions as $version) { - if ( preg_match('/^(?P\d++\.\d++)\.(?P\d++)/', $version, $versionParts) ) { + if ( preg_match('/^(?P\d++\.\d++)(?:\.(?P\d++))?/', $version, $versionParts) ) { if ( $versionParts['majorMinor'] === $update->tested ) { - $actualWpPatchNumber = $versionParts['patch']; - break; + $patch = isset($versionParts['patch']) ? intval($versionParts['patch']) : 0; + if ( $actualWpPatchNumber === null ) { + $actualWpPatchNumber = $patch; + } else { + $actualWpPatchNumber = max($actualWpPatchNumber, $patch); + } } } } + if ( $actualWpPatchNumber === null ) { + $actualWpPatchNumber = 999; + } - $update->tested .= '.' . $actualWpPatchNumber; + if ( $actualWpPatchNumber > 0 ) { + $update->tested .= '.' . $actualWpPatchNumber; + } } /**