Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ["8.1", "8.2", "8.3"]
php-versions: ["8.2", "8.3"]

name: test-master

Expand Down
13 changes: 9 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ public function checkForUpdate() {
if ($version !== '' && $version !== $this->currentVersion) {
$this->updateAvailable = true;
$releaseChannel = $this->getCurrentReleaseChannel();
$updateText = 'Update to ' . htmlentities($versionString) . ' available. (channel: "' . htmlentities($releaseChannel) . '")<br /><span class="light">Following file will be downloaded automatically:</span> <code class="light">' . (string)$response['url'] . '</code>';
$downloadUrl = current($this->getDownloadURLs());
$updateText = 'Update to ' . htmlentities($versionString) . ' available. (channel: "' . htmlentities($releaseChannel) . '")<br /><span class="light">Following file will be downloaded automatically:</span> <code class="light">' . $downloadUrl . '</code>';

// only show changelog link for stable releases (non-RC & non-beta)
if (!preg_match('!(rc|beta)!i', $versionString)) {
Expand Down Expand Up @@ -555,10 +556,10 @@ private function getUpdateServerResponse(): array {
*
* @throws \Exception
*/
public function downloadUpdate(?string $url = null): void {
public function downloadUpdate(string $url = ''): void {
$this->silentLog('[info] downloadUpdate()');

if ($url) {
if ($url !== '') {
// If a URL is provided, use it directly
$downloadURLs = [$url];
} else {
Expand Down Expand Up @@ -599,7 +600,10 @@ public function downloadUpdate(?string $url = null): void {
private function getDownloadURLs(): array {
$response = $this->getUpdateServerResponse();
$downloadURLs = [];
if (!isset($response['downloads']) || !is_array($response['downloads'])) {

if (isset($response['downloads'])) {
$response['downloads'] = (array)$response['downloads'];
} else {
if (isset($response['url']) && is_string($response['url'])) {
// Compatibility with previous verison of updater_server
$ext = pathinfo($response['url'], PATHINFO_EXTENSION);
Expand All @@ -610,6 +614,7 @@ private function getDownloadURLs(): array {
throw new \Exception('Response from update server is missing download URLs');
}
}

foreach ($response['downloads'] as $format => $urls) {
if (!$this->isAbleToDecompress($format)) {
continue;
Expand Down
13 changes: 9 additions & 4 deletions lib/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ public function checkForUpdate() {
if ($version !== '' && $version !== $this->currentVersion) {
$this->updateAvailable = true;
$releaseChannel = $this->getCurrentReleaseChannel();
$updateText = 'Update to ' . htmlentities($versionString) . ' available. (channel: "' . htmlentities($releaseChannel) . '")<br /><span class="light">Following file will be downloaded automatically:</span> <code class="light">' . (string)$response['url'] . '</code>';
$downloadUrl = current($this->getDownloadURLs());
$updateText = 'Update to ' . htmlentities($versionString) . ' available. (channel: "' . htmlentities($releaseChannel) . '")<br /><span class="light">Following file will be downloaded automatically:</span> <code class="light">' . $downloadUrl . '</code>';

// only show changelog link for stable releases (non-RC & non-beta)
if (!preg_match('!(rc|beta)!i', $versionString)) {
Expand Down Expand Up @@ -537,10 +538,10 @@ private function getUpdateServerResponse(): array {
*
* @throws \Exception
*/
public function downloadUpdate(?string $url = null): void {
public function downloadUpdate(string $url = ''): void {
$this->silentLog('[info] downloadUpdate()');

if ($url) {
if ($url !== '') {
// If a URL is provided, use it directly
$downloadURLs = [$url];
} else {
Expand Down Expand Up @@ -581,7 +582,10 @@ public function downloadUpdate(?string $url = null): void {
private function getDownloadURLs(): array {
$response = $this->getUpdateServerResponse();
$downloadURLs = [];
if (!isset($response['downloads']) || !is_array($response['downloads'])) {

if (isset($response['downloads'])) {
$response['downloads'] = (array)$response['downloads'];
} else {
if (isset($response['url']) && is_string($response['url'])) {
// Compatibility with previous verison of updater_server
$ext = pathinfo($response['url'], PATHINFO_EXTENSION);
Expand All @@ -592,6 +596,7 @@ private function getDownloadURLs(): array {
throw new \Exception('Response from update server is missing download URLs');
}
}

foreach ($response['downloads'] as $format => $urls) {
if (!$this->isAbleToDecompress($format)) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion tests/features/master.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ Feature: CLI updater - master base
And the version number is decreased in the config.php to enforce upgrade
When the CLI updater is run successfully
And the output should contain "Update successful"
Then the installed version should be 32.0
Then the installed version should be 33.0
And maintenance mode should be off
And upgrade is not required
Binary file modified updater.phar
Binary file not shown.