Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix legacy update notifications #23175

Merged
merged 1 commit into from
Oct 5, 2020
Merged

Conversation

mrtnmtth
Copy link
Contributor

@mrtnmtth mrtnmtth commented Oct 4, 2020

This fixes issue #21266

Since this is legacy code, I only changed as much as needed to fix the issue

Signed-off-by: mrtnmtth <mrtn.mtth@gmx.de>
@rullzer rullzer requested a review from nickvergessen October 5, 2020 09:41
@rullzer rullzer added this to the Nextcloud 21 milestone Oct 5, 2020
@rullzer rullzer added the 3. to review Waiting for reviews label Oct 5, 2020
@nickvergessen
Copy link
Member

To test on master (where no update can be available), apply the following patch:

diff --git a/apps/updatenotification/lib/AppInfo/Application.php b/apps/updatenotification/lib/AppInfo/Application.php
index 54d6444236..4775c6ece1 100644
--- a/apps/updatenotification/lib/AppInfo/Application.php
+++ b/apps/updatenotification/lib/AppInfo/Application.php
@@ -62,6 +62,9 @@ class Application extends App implements IBootstrap {
                                                                         IGroupManager $groupManager,
                                                                         IAppContainer $appContainer,
                                                                         ILogger $logger) {
+                       Util::addScript('updatenotification', 'legacy-notification');
+                       $updateChecker = $appContainer->get(UpdateChecker::class);
+                       \OC_Hook::connect('\OCP\Config', 'js', $updateChecker, 'populateJavaScriptVariables');
                        if ($config->getSystemValue('updatechecker', true) !== true) {
                                // Updater check is disabled
                                return;
diff --git a/apps/updatenotification/lib/UpdateChecker.php b/apps/updatenotification/lib/UpdateChecker.php
index b83eff8818..7bcc29a4fd 100644
--- a/apps/updatenotification/lib/UpdateChecker.php
+++ b/apps/updatenotification/lib/UpdateChecker.php
@@ -75,7 +75,15 @@ class UpdateChecker {
                        return $result;
                }
 
-               return [];
+               return [
+                       'updateAvailable' => true,
+                       'updateVersion' => '20.0.0',
+                       'updateVersionString' => '20.0.0',
+                       'updaterEnabled' => true,
+                       'versionIsEol' => false,
+                       'updateLink' => 'https://nextcloud.com',
+                       'downloadLink' => 'https://nextcloud.com',
+               ];
        }
 
        /**
@@ -84,8 +92,8 @@ class UpdateChecker {
        public function populateJavaScriptVariables(array $data) {
                $data['array']['oc_updateState'] =  json_encode([
                        'updateAvailable' => true,
-                       'updateVersion' => $this->getUpdateState()['updateVersionString'],
-                       'updateLink' => $this->getUpdateState()['updateLink'] ?? '',
+                       'updateVersion' => '20.0.0',// $this->getUpdateState()['updateVersionString'],
+                       'updateLink' => 'https://nextcloud.com',//  $this->getUpdateState()['updateLink'] ?? '',
                ]);
        }
 }

@nickvergessen nickvergessen merged commit 7511e71 into nextcloud:master Oct 5, 2020
@welcome
Copy link

welcome bot commented Oct 5, 2020

Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

@nickvergessen
Copy link
Member

/backport to stable20

@nickvergessen
Copy link
Member

/backport to stable19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants