Skip to content

Commit

Permalink
Add extendedSupport to Subscription (nextcloud#15922)
Browse files Browse the repository at this point in the history
Add extendedSupport to Subscription
  • Loading branch information
skjnldsv authored Jun 19, 2019
2 parents abb1fd9 + d5805df commit 21d8363
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 5 deletions.
1 change: 1 addition & 0 deletions core/Controller/OCSController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function getCapabilities() {
'micro' => $micro,
'string' => \OC_Util::getVersionString(),
'edition' => '',
'extendedSupport' => \OCP\Util::hasExtendedSupport()
);

if($this->userSession->isLoggedIn()) {
Expand Down
12 changes: 12 additions & 0 deletions lib/private/Support/Subscription/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,16 @@ public function delegateHasValidSubscription(): bool {
}
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;
}
}
7 changes: 7 additions & 0 deletions lib/public/Support/Subscription/IRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,11 @@ public function delegateGetSupportedApps(): array;
* @since 17.0.0
*/
public function delegateHasValidSubscription(): bool;

/**
* Indicates if the subscription has extended support
*
* @since 17.0.0
*/
public function delegateHasExtendedSupport(): bool;
}
7 changes: 7 additions & 0 deletions lib/public/Support/Subscription/ISubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
18 changes: 15 additions & 3 deletions lib/public/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -98,7 +110,7 @@ public static function getVersion() {
public static function setChannel($channel) {
\OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel);
}

/**
* Get current update channel
* @return string
Expand Down Expand Up @@ -501,7 +513,7 @@ public static function isDefaultExpireDateEnforced() {
public static function needUpgrade() {
if (!isset(self::$needUpgradeCache)) {
self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getSystemConfig());
}
}
return self::$needUpgradeCache;
}

Expand Down
6 changes: 4 additions & 2 deletions status.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@
# 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 {
Expand Down
2 changes: 2 additions & 0 deletions tests/Core/Controller/OCSControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function testGetCapabilities() {
'micro' => $micro,
'string' => \OC_Util::getVersionString(),
'edition' => '',
'extendedSupport' => false
);

$capabilities = [
Expand Down Expand Up @@ -128,6 +129,7 @@ public function testGetCapabilitiesPublic() {
'micro' => $micro,
'string' => \OC_Util::getVersionString(),
'edition' => '',
'extendedSupport' => false
);

$capabilities = [
Expand Down
12 changes: 12 additions & 0 deletions tests/lib/Support/Subscription/RegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ public function testDelegateHasValidSubscription() {
$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);
Expand Down

0 comments on commit 21d8363

Please sign in to comment.