Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
use OCP\Group\Events\GroupDeletedEvent;
use OCP\Group\Events\UserAddedEvent;
use OCP\Group\Events\UserRemovedEvent;
use OCP\IServerContainer;
use OCP\Share\IManager as IShareManager;
use OCP\User\Events\UserChangedEvent;
use OCP\User\Events\UserCreatedEvent;
use OCP\User\Events\UserDeletedEvent;
use Psr\Container\ContainerInterface;
use Throwable;

/**
Expand All @@ -81,8 +81,6 @@ class Application extends App implements IBootstrap {

public const CLIENT_TIMEOUT = 3;

private ConfigService $configService;

public function __construct(array $params = []) {
parent::__construct(self::APP_ID, $params);
}
Expand Down Expand Up @@ -129,26 +127,20 @@ public function register(IRegistrationContext $context): void {


/**
* @param IBootContext $context
*
* @throws Throwable
*/
public function boot(IBootContext $context): void {
$serverContainer = $context->getServerContainer();

$context->injectFn(function (IShareManager $shareManager) {
$shareManager->registerShareProvider(ShareByCircleProvider::class);
});

$this->configService = $context->getAppContainer()
->get(ConfigService::class);

$context->injectFn(Closure::fromCallable([$this, 'registerMountProvider']));
}


public function registerMountProvider(IServerContainer $container) {
if (!$this->configService->isGSAvailable()) {
public function registerMountProvider(ContainerInterface $container): void {
$configService = $container->get(ConfigService::class);
if (!$configService->isGSAvailable()) {
return;
}

Expand Down
15 changes: 7 additions & 8 deletions lib/Circles/FileSharingBroadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace OCA\Circles\Circles;

use Exception;
use OC;
use OC\Share20\Share;
use OCA\Circles\AppInfo\Application;
use OCA\Circles\Db\FileSharesRequest;
Expand All @@ -23,7 +22,6 @@
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Service\MiscService;
use OCA\FederatedFileSharing\Notifications;
use OCP\AppFramework\QueryException;
use OCP\Defaults;
use OCP\Federation\ICloudIdManager;
use OCP\Files\IRootFolder;
Expand All @@ -32,12 +30,14 @@
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;
use OCP\Server;
use OCP\Share\Exceptions\IllegalIDChangeException;
use OCP\Share\IShare;
use OCP\Util;
use Psr\Container\ContainerExceptionInterface;
use Psr\Log\LoggerInterface;

/**
Expand All @@ -49,8 +49,7 @@ class FileSharingBroadcaster implements IBroadcaster {
/** @var bool */
private $initiated = false;

/** @var IL10N */
private $l10n = null;
private ?IL10N $l10n = null;

/** @var IMailer */
private $mailer;
Expand Down Expand Up @@ -101,7 +100,7 @@ public function init() {
}

$this->initiated = true;
$this->l10n = OC::$server->getL10N(Application::APP_ID);
$this->l10n = Server::get(IFactory::class)->get(Application::APP_ID);
$this->mailer = Server::get(IMailer::class);
$this->rootFolder = Server::get(IRootFolder::class);
$this->userManager = Server::get(IUserManager::class);
Expand All @@ -114,15 +113,15 @@ public function init() {
$this->tokensRequest = Server::get(TokensRequest::class);
$this->configService = Server::get(ConfigService::class);
$this->miscService = Server::get(MiscService::class);
} catch (QueryException $e) {
} catch (ContainerExceptionInterface $e) {
$this->logger->info('Circles: cannot init FileSharingBroadcaster - ' . $e->getMessage(), ['exception' => $e]);
}

try {
$this->federationNotifications =
Server::get(Notifications::class);
$this->federatedEnabled = true;
} catch (QueryException $e) {
} catch (ContainerExceptionInterface $e) {
}
}

Expand Down Expand Up @@ -388,7 +387,7 @@ private function sharedByMail(

$lang = $this->configService->getCoreValueForUser($share->getSharedBy(), 'lang', '');
if ($lang !== '') {
$this->l10n = OC::$server->getL10N(Application::APP_ID, $lang);
$this->l10n = Server::get(IFactory::class)->get(Application::APP_ID, $lang);
}

$displayName = $this->miscService->getDisplayName($share->getSharedBy());
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version0024Date20220317190331.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt

if ($schema->hasTable('circles_membership')) {
$table = $schema->getTable('circles_membership');
if (!$table->hasPrimaryKey()) {
if ($table->getPrimaryKey() === null) {
$indexes = $table->getIndexes();
// conflict in Oracle with existing unique index, duplicate of primaryKey.
foreach ($indexes as $index) {
Expand Down
5 changes: 3 additions & 2 deletions lib/Model/BaseCircle.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

namespace OCA\Circles\Model;

use OC;
use OCA\Circles\AppInfo\Application;
use OCP\IL10N;
use OCP\L10N\IFactory;
use OCP\Server;

/**
* @deprecated
Expand Down Expand Up @@ -88,7 +89,7 @@ class BaseCircle {
private $links;

public function __construct($type = -1, $name = '') {
$this->l10n = OC::$server->getL10N(Application::APP_ID);
$this->l10n = Server::get(IFactory::class)->get(Application::APP_ID);

if ($type > -1) {
$this->type = $type;
Expand Down
5 changes: 3 additions & 2 deletions lib/Model/BaseMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
namespace OCA\Circles\Model;

use JsonSerializable;
use OC;
use OCA\Circles\AppInfo\Application;
use OCA\Circles\Service\MiscService;
use OCP\IL10N;
use OCP\L10N\IFactory;
use OCP\Server;

/**
* @deprecated
Expand Down Expand Up @@ -91,7 +92,7 @@ class BaseMember implements JsonSerializable {
* @param int $type
*/
public function __construct($userId = '', $type = 0, $circleUniqueId = '') {
$this->l10n = OC::$server->getL10N(Application::APP_ID);
$this->l10n = Server::get(IFactory::class)->get(Application::APP_ID);

$this->setType($type);
$this->setUserId($userId);
Expand Down
36 changes: 15 additions & 21 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use OCA\Circles\Tools\Traits\TArrayTools;
use OCA\Circles\Tools\Traits\TNCLogger;
use OCA\Circles\Tools\Traits\TStringTools;
use OCP\AppFramework\Services\IAppConfig;
use OCP\Config\IUserConfig;
use OCP\IConfig;
use OCP\IURLGenerator;

Expand Down Expand Up @@ -191,23 +193,19 @@ class ConfigService {
public const DISPLAY_PARENTHESIS = 2;


/** @var IConfig */
private $config;

/** @var IURLGenerator */
private $urlGenerator;


/**
* ConfigService constructor.
*
* @param IConfig $config
* @param IURLGenerator $urlGenerator
*/
public function __construct(IConfig $config, IURLGenerator $urlGenerator) {
$this->config = $config;
$this->urlGenerator = $urlGenerator;

public function __construct(
private readonly IConfig $config,
private readonly IAppConfig $appConfig,
private readonly IUserConfig $userConfig,
private readonly \OCP\IAppConfig $globalAppConfig,
private readonly IURLGenerator $urlGenerator,
) {
$this->setup('app', Application::APP_ID);
}

Expand All @@ -220,7 +218,7 @@ public function __construct(IConfig $config, IURLGenerator $urlGenerator) {
* @return string
*/
public function getAppValue(string $key): string {
if (($value = $this->config->getAppValue(Application::APP_ID, $key, '')) !== '') {
if (($value = $this->appConfig->getAppValueString($key)) !== '') {
return $value;
}

Expand Down Expand Up @@ -259,15 +257,15 @@ public function getAppValueBool(string $key): bool {
* @return void
*/
public function setAppValue(string $key, string $value): void {
$this->config->setAppValue(Application::APP_ID, $key, $value);
$this->appConfig->setAppValueString($key, $value);
}


/**
*
*/
public function unsetAppConfig(): void {
$this->config->deleteAppValues(Application::APP_ID);
$this->appConfig->deleteAppValues();
}


Expand All @@ -293,7 +291,7 @@ public function getAvailableHosts(): array {
* @return string
*/
public function getCoreValueForUser($userId, $key, $default = '') {
return $this->config->getUserValue($userId, 'core', $key, $default);
return $this->userConfig->getValueString($userId, 'core', $key, $default);
}


Expand Down Expand Up @@ -365,11 +363,7 @@ public function isSinglePasswordAvailable(Circle $circle): bool {
* @return bool
*/
public function enforcePasswordOnSharedFile(Circle $circle): bool {
if ($this->config->getAppValue(
'core',
'shareapi_enforce_links_password',
'no'
) === 'yes') {
if ($this->globalAppConfig->getValueBool('core', 'shareapi_enforce_links_password')) {
return true;
}

Expand Down Expand Up @@ -590,7 +584,7 @@ public function getFrontalInstance(): string {

// using old settings local_cloud_id from NC20, deprecated in NC25
if ($frontalCloudId === '') {
$frontalCloudId = $this->config->getAppValue(Application::APP_ID, 'local_cloud_id', '');
$frontalCloudId = $this->appConfig->getAppValueString('local_cloud_id');
if ($frontalCloudId !== '') {
$this->setAppValue(self::FRONTAL_CLOUD_ID, $frontalCloudId);
}
Expand Down
29 changes: 0 additions & 29 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
<code><![CDATA[str_starts_with($sK, '_')]]></code>
</TypeDoesNotContainType>
</file>
<file src="lib/AppInfo/Application.php">
<DeprecatedInterface>
<code><![CDATA[$context->getAppContainer()]]></code>
<code><![CDATA[$context->getServerContainer()]]></code>
<code><![CDATA[IServerContainer]]></code>
</DeprecatedInterface>
</file>
<file src="lib/Circles/FileSharingBroadcaster.php">
<DeprecatedClass>
<code><![CDATA[FileSharesRequest]]></code>
Expand All @@ -28,8 +21,6 @@
<code><![CDATA[MiscService::getContactData($contactId)]]></code>
<code><![CDATA[MiscService::getContactData($contactId)]]></code>
<code><![CDATA[MiscService::getContactData($member->getUserId())]]></code>
<code><![CDATA[getL10N]]></code>
<code><![CDATA[getL10N]]></code>
</DeprecatedMethod>
<InvalidScalarArgument>
<code><![CDATA[$share->getId()]]></code>
Expand Down Expand Up @@ -155,15 +146,7 @@
<code><![CDATA[Types]]></code>
</UndefinedClass>
</file>
<file src="lib/Migration/Version0024Date20220317190331.php">
<DeprecatedMethod>
<code><![CDATA[hasPrimaryKey]]></code>
</DeprecatedMethod>
</file>
<file src="lib/Model/BaseCircle.php">
<DeprecatedMethod>
<code><![CDATA[getL10N]]></code>
</DeprecatedMethod>
<FalsableReturnStatement>
<code><![CDATA[json_encode($this->settings)]]></code>
</FalsableReturnStatement>
Expand All @@ -178,9 +161,6 @@
</RedundantCast>
</file>
<file src="lib/Model/BaseMember.php">
<DeprecatedMethod>
<code><![CDATA[getL10N]]></code>
</DeprecatedMethod>
<InvalidNullableReturnType>
<code><![CDATA[DeprecatedMember]]></code>
</InvalidNullableReturnType>
Expand Down Expand Up @@ -349,15 +329,6 @@
<code><![CDATA[search]]></code>
</DeprecatedMethod>
</file>
<file src="lib/Service/ConfigService.php">
<DeprecatedMethod>
<code><![CDATA[deleteAppValues]]></code>
<code><![CDATA[getAppValue]]></code>
<code><![CDATA[getAppValue]]></code>
<code><![CDATA[getAppValue]]></code>
<code><![CDATA[setAppValue]]></code>
</DeprecatedMethod>
</file>
<file src="lib/Service/FederatedShareService.php">
<InvalidMethodCall>
<code><![CDATA[gObj]]></code>
Expand Down
Loading