Skip to content

Commit 79930f6

Browse files
committed
Remove OCP\App and OCP\BackgroundJob
Both deprecated since NC 23 IAppManager is the replacement for OCP\App unfortunately it can't be dependency injected in classes used by the installed otherwise the database connection is initialised too early Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent d3f66e2 commit 79930f6

27 files changed

Lines changed: 118 additions & 262 deletions

File tree

apps/dav/lib/Connector/Sabre/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ public function getContentType() {
553553
* @return array|bool
554554
*/
555555
public function getDirectDownload() {
556-
if (\OCP\App::isEnabled('encryption')) {
556+
if (\OCP\Server::get(\OCP\App\IAppManager::class)->isEnabledForUser('encryption')) {
557557
return [];
558558
}
559559
/** @var \OCP\Files\Storage $storage */

apps/encryption/templates/mail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<table cellspacing="0" cellpadding="0" border="0" width="600px">
88
<tr>
99
<td colspan="2" bgcolor="<?php p($theme->getColorPrimary());?>">
10-
<img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL(image_path('', 'logo-mail.png'))); ?>" alt="<?php p($theme->getName()); ?>"/>
10+
<img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL(image_path('core', 'logo-mail.png'))); ?>" alt="<?php p($theme->getName()); ?>"/>
1111
</td>
1212
</tr>
1313
<tr><td colspan="2">&nbsp;</td></tr>

apps/federatedfilesharing/lib/Controller/RequestHandlerController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use OCP\AppFramework\OCS\OCSException;
3636
use OCP\AppFramework\OCS\OCSForbiddenException;
3737
use OCP\AppFramework\OCSController;
38+
use OCP\App\IAppManager;
3839
use OCP\Constants;
3940
use OCP\EventDispatcher\IEventDispatcher;
4041
use OCP\Federation\Exceptions\ProviderCouldNotAddShareException;
@@ -366,7 +367,7 @@ public function revoke($id) {
366367
* @return bool
367368
*/
368369
private function isS2SEnabled($incoming = false) {
369-
$result = \OCP\App::isEnabled('files_sharing');
370+
$result = \OCP\Server::get(IAppManager::class)->isEnabledForUser('files_sharing');
370371

371372
if ($incoming) {
372373
$result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled();

apps/files_trashbin/lib/Trashbin.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
use OCA\Files_Trashbin\AppInfo\Application;
5555
use OCA\Files_Trashbin\Command\Expire;
5656
use OCP\AppFramework\Utility\ITimeFactory;
57+
use OCP\App\IAppManager;
5758
use OCP\Files\File;
5859
use OCP\Files\Folder;
5960
use OCP\Files\NotFoundException;
@@ -395,7 +396,7 @@ public static function move2trash($file_path, $ownerOnly = false) {
395396
* @param integer $timestamp when the file was deleted
396397
*/
397398
private static function retainVersions($filename, $owner, $ownerPath, $timestamp) {
398-
if (\OCP\App::isEnabled('files_versions') && !empty($ownerPath)) {
399+
if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions') && !empty($ownerPath)) {
399400
$user = OC_User::getUser();
400401
$rootView = new View('/');
401402

@@ -543,7 +544,7 @@ public static function restore($file, $filename, $timestamp) {
543544
* @return false|null
544545
*/
545546
private static function restoreVersions(View $view, $file, $filename, $uniqueFilename, $location, $timestamp) {
546-
if (\OCP\App::isEnabled('files_versions')) {
547+
if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
547548
$user = OC_User::getUser();
548549
$rootView = new View('/');
549550

@@ -704,7 +705,7 @@ public static function delete($filename, $user, $timestamp = null) {
704705
*/
705706
private static function deleteVersions(View $view, $file, $filename, $timestamp, $user) {
706707
$size = 0;
707-
if (\OCP\App::isEnabled('files_versions')) {
708+
if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
708709
if ($view->is_dir('files_trashbin/versions/' . $file)) {
709710
$size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file));
710711
$view->unlink('files_trashbin/versions/' . $file);

apps/provisioning_api/tests/Controller/AppsControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function setUp(): void {
6767

6868
public function testGetAppInfo() {
6969
$result = $this->api->getAppInfo('provisioning_api');
70-
$expected = \OC_App::getAppInfo('provisioning_api');
70+
$expected = $this->appManager->getAppInfo('provisioning_api');
7171
$this->assertEquals($expected, $result->getData());
7272
}
7373

apps/user_ldap/templates/part.settingcontrols.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</button>
55
<a href="<?php p(link_to_docs('admin-ldap')); ?>"
66
target="_blank" rel="noreferrer noopener">
7-
<img src="<?php print_unescaped(image_path('', 'actions/info.svg')); ?>"
7+
<img src="<?php print_unescaped(image_path('core', 'actions/info.svg')); ?>"
88
style="height:1.75ex" />
99
<?php p($l->t('Help'));?>
1010
</a>

apps/user_ldap/templates/part.wizardcontrols.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</button>
1111
<a href="<?php p(link_to_docs('admin-ldap')); ?>"
1212
target="_blank" rel="noreferrer noopener">
13-
<img src="<?php print_unescaped(image_path('', 'actions/info.svg')); ?>"
13+
<img src="<?php print_unescaped(image_path('core', 'actions/info.svg')); ?>"
1414
style="height:1.75ex" />
1515
<span class="ldap_grey"><?php p($l->t('Help'));?></span>
1616
</a>

core/Command/Maintenance/Repair.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8282
if (!$this->appManager->isEnabledForUser($app)) {
8383
continue;
8484
}
85-
$info = \OC_App::getAppInfo($app);
85+
$info = $this->appManager->getAppInfo($app);
8686
if (!is_array($info)) {
8787
continue;
8888
}

core/Command/User/ResetPassword.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
namespace OC\Core\Command\User;
2929

3030
use OC\Core\Command\Base;
31+
use OCP\App\IAppManager;
3132
use OCP\IUser;
3233
use OCP\IUserManager;
3334
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
@@ -41,10 +42,12 @@
4142

4243
class ResetPassword extends Base {
4344
protected IUserManager $userManager;
45+
private IAppManager $appManager;
4446

45-
public function __construct(IUserManager $userManager) {
46-
$this->userManager = $userManager;
47+
public function __construct(IUserManager $userManager, IAppManager $appManager) {
4748
parent::__construct();
49+
$this->userManager = $userManager;
50+
$this->appManager = $appManager;
4851
}
4952

5053
protected function configure() {
@@ -84,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8487
/** @var QuestionHelper $helper */
8588
$helper = $this->getHelper('question');
8689

87-
if (\OCP\App::isEnabled('encryption')) {
90+
if ($this->appManager->isEnabledForUser('encryption', $user)) {
8891
$output->writeln(
8992
'<error>Warning: Resetting the password when using encryption will result in data loss!</error>'
9093
);

core/register_command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
$application->add(new OC\Core\Command\User\Enable(\OC::$server->getUserManager()));
184184
$application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager()));
185185
$application->add(\OC::$server->get(\OC\Core\Command\User\Report::class));
186-
$application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager()));
186+
$application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager(), \OC::$server->getAppManager()));
187187
$application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig()));
188188
$application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
189189
$application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));

0 commit comments

Comments
 (0)