From afddb81acfa291ba8043d6af974f97abe8ec5243 Mon Sep 17 00:00:00 2001 From: Matt Friedman <maf675@gmail.com> Date: Fri, 24 Mar 2017 11:45:11 -0700 Subject: [PATCH] [ticket/15142] Handle versions for unmatched branches PHPBB3-15142 --- phpBB/phpbb/version_helper.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/phpBB/phpbb/version_helper.php b/phpBB/phpbb/version_helper.php index c613885909..614c93d781 100644 --- a/phpBB/phpbb/version_helper.php +++ b/phpBB/phpbb/version_helper.php @@ -274,12 +274,20 @@ class version_helper $branches = array_filter(array_keys($versions), function($branch) use ($self, $current_branch) { return $self->compare($branch, $current_branch, '>='); }); - $versions = array_intersect_key($versions, array_flip($branches)); + $versions = !empty($branches) ? array_intersect_key($versions, array_flip($branches)) : $versions; + if (!empty($branches)) + { + $versions = array_intersect_key($versions, array_flip($branches)); + } + else + { + // If branches are empty, it means the current phpBB branch is newer than any branch the + // extension was validated against. Reverse sort the versions array so we get the newest + // validated release available. + krsort($versions); + } - // CDB reverse sorts extension versions, so we need to resort them - ksort($versions); - - // Get the lowest version from the previous list. + // Get the first available version from the previous list. $update_info = array_reduce($versions, function($value, $data) use ($self, $current_version) { if ($value === null && $self->compare($data['current'], $current_version, '>=')) {