aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/updateController.php
diff options
context:
space:
mode:
authorGravatar maTh <math-home@web.de> 2023-06-13 22:39:33 +0200
committerGravatar GitHub <noreply@github.com> 2023-06-13 22:39:33 +0200
commit3d9e0c47ecb19fea4f194d3a4a81d7d931e2bc0b (patch)
tree52ca8a7131822807d5cd1e7188b42100594d2988 /app/Controllers/updateController.php
parent67130bca3aa0a8d225c43df57a08cf8c81995136 (diff)
Improved: update page (#5420)
* prependTitle() * do not need the "damn" in the alert * update page layout improved * release channel * i18n labels * add log messages while updating * Delete updatee.php * Update updateController.php * Update updateController.php * Update updateController.php * Update updateController.php * add getCurrentGitBranch() * Update updateController.php * state2 buttons * i18n * loading * Update feedback.php * Update feedback.php * Update feedback.php * Update extra.js * Apply suggestions from code review Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com> * Update updateController.php * Update terminology * update button is now armed --------- Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com> Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Controllers/updateController.php')
-rw-r--r--app/Controllers/updateController.php34
1 files changed, 29 insertions, 5 deletions
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index a9cc8c334..241184090 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -44,6 +44,16 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
return true;
}
+ public static function getCurrentGitBranch(): string {
+ $output = [];
+ exec('git branch --show-current', $output, $return);
+ if ($return === 0) {
+ return 'git branch: ' . $output[0];
+ } else {
+ return 'git';
+ }
+ }
+
public static function hasGitUpdate(): bool {
$cwd = getcwd();
if ($cwd === false) {
@@ -72,6 +82,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
/** @return string|true */
public static function gitPull() {
+ Minz_Log::notice(_t('admin.update.viaGit'));
$cwd = getcwd();
if ($cwd === false) {
Minz_Log::warning('getcwd() failed');
@@ -110,6 +121,8 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
invalidateHttpCache();
+ $this->view->is_release_channel_stable = $this->is_release_channel_stable(FRESHRSS_VERSION);
+
$this->view->update_to_apply = false;
$this->view->last_update_time = 'unknown';
$timestamp = @filemtime(join_path(DATA_PATH, self::LASTUPDATEFILE));
@@ -144,7 +157,17 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
}
}
+ private function is_release_channel_stable(string $currentVersion): bool {
+ return strpos($currentVersion, 'dev') === false &&
+ strpos($currentVersion, 'edge') === false;
+ }
+
+ /* Check installation if there is a newer version.
+ via Git, if available.
+ Else via system configuration auto_update_url
+ */
public function checkAction(): void {
+ FreshRSS_View::prependTitle(_t('admin.update.title') . ' ยท ');
$this->view->_path('update/index.phtml');
if (file_exists(UPDATE_FILENAME)) {
@@ -160,11 +183,10 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
if (self::isGit()) {
if (self::hasGitUpdate()) {
- $version = 'git';
+ $version = self::getCurrentGitBranch();
} else {
$this->view->message = array(
'status' => 'latest',
- 'title' => _t('gen.short.damn'),
'body' => _t('feedback.update.none')
);
@touch(join_path(DATA_PATH, self::LASTUPDATEFILE));
@@ -199,7 +221,6 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
$this->view->message = array(
'status' => 'bad',
- 'title' => _t('gen.short.damn'),
'body' => _t('feedback.update.server_not_found', $auto_update_url)
);
return;
@@ -210,7 +231,6 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
if (strpos($status, 'UPDATE') !== 0) {
$this->view->message = array(
'status' => 'latest',
- 'title' => _t('gen.short.damn'),
'body' => _t('feedback.update.none')
);
@touch(join_path(DATA_PATH, self::LASTUPDATEFILE));
@@ -220,6 +240,8 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
$script = $res_array[1];
$version = explode(' ', $status, 2);
$version = $version[1];
+
+ Minz_Log::notice(_t('admin.update.copiedFromURL', $auto_update_url));
}
if (file_put_contents(UPDATE_FILENAME, $script) !== false) {
@@ -228,7 +250,6 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
} else {
$this->view->message = array(
'status' => 'bad',
- 'title' => _t('gen.short.damn'),
'body' => _t('feedback.update.error', 'Cannot save the update script')
);
}
@@ -253,8 +274,10 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
if ($res === true) {
@unlink(UPDATE_FILENAME);
@file_put_contents(join_path(DATA_PATH, self::LASTUPDATEFILE), '');
+ Minz_Log::notice(_t('feedback.update.finished'));
Minz_Request::good(_t('feedback.update.finished'));
} else {
+ Minz_Log::error(_t('feedback.update.error', $res));
Minz_Request::bad(_t('feedback.update.error', $res), [ 'c' => 'update', 'a' => 'index' ]);
}
} else {
@@ -288,6 +311,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
'params' => array('post_conf' => '1')
), true);
} else {
+ Minz_Log::error(_t('feedback.update.error', $res));
Minz_Request::bad(_t('feedback.update.error', $res), [ 'c' => 'update', 'a' => 'index' ]);
}
}