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
13 changes: 9 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,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 @@ -546,10 +547,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 @@ -590,7 +591,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 @@ -601,6 +605,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 @@ -122,7 +122,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 @@ -508,10 +509,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 @@ -552,7 +553,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 @@ -563,6 +567,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
Binary file modified updater.phar
Binary file not shown.
Loading