From 2fb701089d3dd3f87dea1ab1321a862b1e10d862 Mon Sep 17 00:00:00 2001 From: Franky Van Liedekerke Date: Sun, 1 Jan 2023 22:26:25 +0100 Subject: [PATCH 1/2] Fix GitHub assets array_filter keeps the index, so if the asset matching has index 1, an array with key 1 is returned. However, further down, $matchingAssets[0] is always used. This will then fail. Using array_values after array_filter resets the indexes on the array from 0, solving the problem. --- Puc/v5p0/Vcs/GitHubApi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Puc/v5p0/Vcs/GitHubApi.php b/Puc/v5p0/Vcs/GitHubApi.php index 940c7ac..81a9d03 100644 --- a/Puc/v5p0/Vcs/GitHubApi.php +++ b/Puc/v5p0/Vcs/GitHubApi.php @@ -114,7 +114,7 @@ if ( !class_exists(GitHubApi::class, false) ): if ( $this->releaseAssetsEnabled ) { //Use the first release asset that matches the specified regular expression. if ( isset($release->assets, $release->assets[0]) ) { - $matchingAssets = array_filter($release->assets, array($this, 'matchesAssetFilter')); + $matchingAssets = array_values(array_filter($release->assets, array($this, 'matchesAssetFilter'))); } else { $matchingAssets = array(); } From 75c05617ec5c6149d7eb876afdc55d1613c6c0e3 Mon Sep 17 00:00:00 2001 From: Franky Van Liedekerke Date: Sun, 1 Jan 2023 22:34:49 +0100 Subject: [PATCH 2/2] Also allow "main" as branch for github assets When setting $myUpdateChecker->setBranch('main'); the setting enableReleaseAssets was ignored. But since on newer versions "main" is the default (and not "master"), it should allow it. --- Puc/v5p0/Vcs/GitHubApi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Puc/v5p0/Vcs/GitHubApi.php b/Puc/v5p0/Vcs/GitHubApi.php index 81a9d03..c8bd429 100644 --- a/Puc/v5p0/Vcs/GitHubApi.php +++ b/Puc/v5p0/Vcs/GitHubApi.php @@ -358,7 +358,7 @@ if ( !class_exists(GitHubApi::class, false) ): protected function getUpdateDetectionStrategies($configBranch) { $strategies = array(); - if ( $configBranch === 'master' ) { + if ( $configBranch === 'master' || $configBranch === 'main') { //Use the latest release. $strategies[self::STRATEGY_LATEST_RELEASE] = array($this, 'getLatestRelease'); //Failing that, use the tag with the highest version number.