[TikiWiki-commits] [Git][tikiwiki/tiki][master] [ENH] UpgradeNotice: Improve upgrade notice for VCS versions
Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <69379f4282274_2a56cff709516@gitlab-sidekiq-low-urgency-cpu-bound-v2-66d95699db-ldhk7.mail> |
Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
c37fa397 by King KAMBALE DAVID at 2025-12-09T03:53:58+00:00
[ENH] UpgradeNotice: Improve upgrade notice for VCS versions
---
* [ENH] UpgradeNotice: Improve upgrade notice for VCS versions
See merge request tikiwiki/tiki!7166
- - - - -
6 changed files:
- lib/core/Tiki/Version/Checker.php
- lib/core/Tiki/Version/Upgrade.php
- lib/core/Tiki/Version/Version.php
- lib/test/TikiVersionTest.php
- templates/tiki-admin.tpl
- tiki-admin.php
Changes:
=====================================
lib/core/Tiki/Version/Checker.php
=====================================
@@ -28,7 +28,7 @@ class Tiki_Version_Checker
$versions = $this->getSupportedVersions($content);
if ($supported = $this->findSupportedInBranch($versions)) {
- if ($supported->isUpgradeTo($this->version)) {
+ if ($supported->isStableUpgradeTo($this->version)) {
$upgrades[] = new Tiki_Version_Upgrade($this->version, $supported, true);
$branchupdate = $supported;
}
@@ -36,7 +36,7 @@ class Tiki_Version_Checker
$max = $this->getLatestVersion($versions);
- if ($max !== $branchupdate && $max->isUpgradeTo($this->version)) {
+ if ($max !== $branchupdate && (! $this->version->isStable() || $max->isStableUpgradeTo($this->version))) {
$upgrades[] = new Tiki_Version_Upgrade($supported ?: $this->version, $max, $supported === false);
}
@@ -64,7 +64,7 @@ class Tiki_Version_Checker
$max = array_shift($versions);
foreach ($versions as $candidate) {
- if ($candidate->isUpgradeTo($max)) {
+ if ($candidate->isStableUpgradeTo($max)) {
$max = $candidate;
}
}
=====================================
lib/core/Tiki/Version/Upgrade.php
=====================================
@@ -21,7 +21,21 @@ class Tiki_Version_Upgrade
public function getMessage()
{
$parts = [];
- if ($this->isRequired) {
+ if (! $this->old->isStable()) {
+ if ($this->new->isStableUpgradeTo($this->old)) {
+ $parts[] = tr(
+ 'You are using a development version: %0. This version is intended for testing and development purposes. For stability, consider switching to the latest stable release: %1.',
+ (string) $this->old,
+ (string) $this->new
+ );
+ } else {
+ $parts[] = tr(
+ 'You are using a development version: %0. This version is intended for testing and development purposes. The latest stable release (%1) is older than your current version, so downgrading is not recommended.',
+ (string) $this->old,
+ (string) $this->new
+ );
+ }
+ } elseif ($this->isRequired) {
$parts[] = tr('Version %0 is no longer supported.', (string) $this->old);
if ($this->isMinor()) {
=====================================
lib/core/Tiki/Version/Version.php
=====================================
@@ -42,6 +42,11 @@ class Tiki_Version_Version
return $this->major;
}
+ public function isStable()
+ {
+ return empty($this->sub);
+ }
+
public function isUpgradeTo($version)
{
// Note that this does not cover all cases, upgrades are only official releases
@@ -59,6 +64,15 @@ class Tiki_Version_Version
}
}
+ public function isStableUpgradeTo($version)
+ {
+ if (! $this->isStable()) {
+ return false;
+ }
+
+ return $this->isUpgradeTo($version);
+ }
+
public function __toString()
{
$string = "{$this->major}.{$this->minor}";
=====================================
lib/test/TikiVersionTest.php
=====================================
@@ -197,6 +197,33 @@ O;
['Version 8.2 is no longer supported. A minor upgrade to 8.4 is strongly recommended.', new Tiki_Version_Upgrade('8.2', '8.4', true)],
['Version 4.3 is no longer supported. A major upgrade to 9.0 is strongly recommended.', new Tiki_Version_Upgrade('4.3', '9.0', true)],
['Version 8.4 is still supported. However, a major upgrade to 9.0 is available.', new Tiki_Version_Upgrade('8.4', '9.0', false)],
+ ['You are using a development version: 9.0beta2. This version is intended for testing and development purposes. For stability, consider switching to the latest stable release: 9.0.', new Tiki_Version_Upgrade('9.0beta2', '9.0', false)],
+ ['You are using a development version: 10.0vcs. This version is intended for testing and development purposes. The latest stable release (9.0) is older than your current version, so downgrading is not recommended.', new Tiki_Version_Upgrade('10.0vcs', '9.0', false)],
];
}
+
+ public function testIsStable()
+ {
+ $this->assertTrue(Tiki_Version_Version::get('27.1')->isStable());
+ $this->assertFalse(Tiki_Version_Version::get('27.1vcs')->isStable());
+ $this->assertFalse(Tiki_Version_Version::get('28.0beta')->isStable());
+ $this->assertFalse(Tiki_Version_Version::get('27.0rc')->isStable());
+ $this->assertFalse(Tiki_Version_Version::get('27.0pre')->isStable());
+ $this->assertTrue(Tiki_Version_Version::get('25.5')->isStable());
+ }
+
+ public function testUnstableVersionComparison()
+ {
+ // Upgrade: unstable to stable (e.g., beta → final)
+ $unstable = Tiki_Version_Version::get('27.0beta');
+ $stable = Tiki_Version_Version::get('27.0');
+ $this->assertTrue($stable->isStableUpgradeTo($unstable));
+ $this->assertFalse($unstable->isStableUpgradeTo($stable));
+
+ // Downgrade: unstable version is newer than last stable
+ $unstable = Tiki_Version_Version::get('29.0vcs');
+ $stable = Tiki_Version_Version::get('28.4');
+ $this->assertFalse($unstable->isStableUpgradeTo($stable));
+ $this->assertFalse($stable->isStableUpgradeTo($unstable));
+ }
}
=====================================
templates/tiki-admin.tpl
=====================================
@@ -197,7 +197,9 @@
</div>
{if $upgrade_messages|count}
- {if $upgrade_messages|count eq 1}
+ {if not $is_stable}
+ {$title="{tr}Stable version available{/tr}"}
+ {elseif $upgrade_messages|count eq 1}
{$title="{tr}Upgrade Available{/tr}"}
{else}
{$title="{tr}Upgrades Available{/tr}"}
=====================================
tiki-admin.php
=====================================
@@ -363,20 +363,20 @@ $smarty->assign('ProblemsLoadingCacheSubSystem', TikiLib::lib('cache')->reportOp
// VERSION TRACKING
$forcecheck = ! empty($_GET['forcecheck']);
+$versionObj = Tiki_Version_Version::get($TWV->version);
+$is_stable = $versionObj->isStable();
+
// Versioning feature has been enabled, so if the time is right, do a live
// check, otherwise display the stored data.
if ($prefs['feature_version_checks'] == 'y' || $forcecheck) {
$versionUtils = new Tiki_Version_Utils();
$upgrades = $versionUtils->checkUpdatesForVersion($TWV->version);
- $gitlib = TikiLib::lib('git');
- $gitDetails = $gitlib->isGitInstall() ? $gitlib->getGitDetails()['content'] : [];
-
$smarty->assign('upgrade_messages', $upgrades);
- $smarty->assign('git_details', $gitDetails);
+ $smarty->assign('is_stable', $is_stable);
} else {
$smarty->assign('upgrade_messages', []);
- $smarty->assign('git_details', []);
+ $smarty->assign('is_stable', $is_stable);
}
// SSL setup
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/c37fa3979914db841061c7edde1f05e7ac613628
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/c37fa3979914db841061c7edde1f05e7ac613628
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs