diff --git a/core/Controller/OCSController.php b/core/Controller/OCSController.php index 278e01403a7314eee1876f355c074a1bb126090b..68861ce7e952fd21e84b18a7e0a99863ba3080c2 100644 --- a/core/Controller/OCSController.php +++ b/core/Controller/OCSController.php @@ -97,6 +97,7 @@ class OCSController extends \OCP\AppFramework\OCSController { 'micro' => $micro, 'string' => \OC_Util::getVersionString(), 'edition' => '', + 'extendedSupport' => \OCP\Util::hasExtendedSupport() ); if($this->userSession->isLoggedIn()) { diff --git a/lib/private/Support/Subscription/Registry.php b/lib/private/Support/Subscription/Registry.php index 89439cb81421f70df431722aedbdbf19b08365d0..c731da4f3b784735f90cb2246a22bfd541ffc93f 100644 --- a/lib/private/Support/Subscription/Registry.php +++ b/lib/private/Support/Subscription/Registry.php @@ -72,4 +72,16 @@ class Registry implements IRegistry { } return false; } + + /** + * Indicates if the subscription has extended support + * + * @since 17.0.0 + */ + public function delegateHasExtendedSupport(): bool { + if ($this->subscription instanceof ISubscription && method_exists($this->subscription, 'hasExtendedSupport')) { + return $this->subscription->hasExtendedSupport(); + } + return false; + } } diff --git a/lib/public/Support/Subscription/IRegistry.php b/lib/public/Support/Subscription/IRegistry.php index 7782f201f284b34097558c5d5fccbde2ecd17927..f13bff597d0be375806cc4c9e4fbb9eecd4b88b2 100644 --- a/lib/public/Support/Subscription/IRegistry.php +++ b/lib/public/Support/Subscription/IRegistry.php @@ -54,4 +54,11 @@ interface IRegistry { * @since 17.0.0 */ public function delegateHasValidSubscription(): bool; + + /** + * Indicates if the subscription has extended support + * + * @since 17.0.0 + */ + public function delegateHasExtendedSupport(): bool; } diff --git a/lib/public/Support/Subscription/ISubscription.php b/lib/public/Support/Subscription/ISubscription.php index fc53fe08da3a9de9294d2eba8f38f4fffc6c05ef..81333609119c742646a1d8fb84e79858a3c3807d 100644 --- a/lib/public/Support/Subscription/ISubscription.php +++ b/lib/public/Support/Subscription/ISubscription.php @@ -34,4 +34,11 @@ interface ISubscription { * @since 17.0.0 */ public function hasValidSubscription(): bool; + + /** + * Indicates if the subscription has extended support + * + * @since 17.0.0 + */ + public function hasExtendedSupport(): bool; } diff --git a/lib/public/Util.php b/lib/public/Util.php index 302eb8d035eba215511d80a04c40248c016ad168..7e9f6b2efbc60cd06167feb07e50576914524de2 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -89,7 +89,19 @@ class Util { public static function getVersion() { return \OC_Util::getVersion(); } - + + /** + * @since 17.0.0 + */ + public static function hasExtendedSupport(): bool { + try { + /** @var \OCP\Support\Subscription\IRegistry */ + $subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class); + return $subscriptionRegistry->delegateHasExtendedSupport(); + } catch (AppFramework\QueryException $e) {} + return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false); + } + /** * Set current update channel * @param string $channel @@ -98,7 +110,7 @@ class Util { public static function setChannel($channel) { \OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel); } - + /** * Get current update channel * @return string @@ -501,7 +513,7 @@ class Util { public static function needUpgrade() { if (!isset(self::$needUpgradeCache)) { self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getSystemConfig()); - } + } return self::$needUpgradeCache; } diff --git a/status.php b/status.php index 274a2edc610d7bbc1f432fea518b400fd10b0295..a42af5a6b6894d362ca491cac75052f3831dd60b 100644 --- a/status.php +++ b/status.php @@ -42,14 +42,16 @@ try { # see core/lib/private/legacy/defaults.php and core/themes/example/defaults.php # for description and defaults $defaults = new \OCP\Defaults(); - $values=array( + $values = [ 'installed'=>$installed, 'maintenance' => $maintenance, 'needsDbUpgrade' => \OCP\Util::needUpgrade(), 'version'=>implode('.', \OCP\Util::getVersion()), 'versionstring'=>OC_Util::getVersionString(), 'edition'=> '', - 'productname'=>$defaults->getName()); + 'productname'=>$defaults->getName(), + 'extendedSupport' => \OCP\Util::hasExtendedSupport() + ]; if (OC::$CLI) { print_r($values); } else { diff --git a/tests/Core/Controller/OCSControllerTest.php b/tests/Core/Controller/OCSControllerTest.php index aa2c780f82e174ea9e082f33f26fb9febaa7842f..a22c3bdc5e0a5d4a48d201b503030c3fb02b45ca 100644 --- a/tests/Core/Controller/OCSControllerTest.php +++ b/tests/Core/Controller/OCSControllerTest.php @@ -97,6 +97,7 @@ class OCSControllerTest extends TestCase { 'micro' => $micro, 'string' => \OC_Util::getVersionString(), 'edition' => '', + 'extendedSupport' => false ); $capabilities = [ @@ -128,6 +129,7 @@ class OCSControllerTest extends TestCase { 'micro' => $micro, 'string' => \OC_Util::getVersionString(), 'edition' => '', + 'extendedSupport' => false ); $capabilities = [ diff --git a/tests/lib/Support/Subscription/RegistryTest.php b/tests/lib/Support/Subscription/RegistryTest.php index 21dad6e50e143933b0cbc675cde5b65ab718cdf1..c9557def0fde29c6c53388f98a70f1c0de5fead1 100644 --- a/tests/lib/Support/Subscription/RegistryTest.php +++ b/tests/lib/Support/Subscription/RegistryTest.php @@ -74,6 +74,18 @@ class RegistryTest extends TestCase { $this->assertSame(true, $this->registry->delegateHasValidSubscription()); } + public function testDelegateHasExtendedSupport() { + /* @var ISubscription|\PHPUnit_Framework_MockObject_MockObject $subscription */ + $subscription = $this->createMock(ISubscription::class); + $subscription->expects($this->once()) + ->method('hasExtendedSupport') + ->willReturn(true); + $this->registry->register($subscription); + + $this->assertSame(true, $this->registry->delegateHasExtendedSupport()); + } + + public function testDelegateGetSupportedApps() { /* @var ISupportedApps|\PHPUnit_Framework_MockObject_MockObject $subscription */ $subscription = $this->createMock(ISupportedApps::class);