Skip to content

Commit f5b7881

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 6fdeb9b commit f5b7881

File tree

27 files changed

+120
-265
lines changed

27 files changed

+120
-265
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ public function getContentType() {
542542
* @return array|bool
543543
*/
544544
public function getDirectDownload() {
545-
if (\OCP\App::isEnabled('encryption')) {
545+
if (\OCP\Server::get(\OCP\App\IAppManager::class)->isEnabledForUser('encryption')) {
546546
return [];
547547
}
548548
/** @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)->isEnabled('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;
@@ -389,7 +390,7 @@ public static function move2trash($file_path, $ownerOnly = false) {
389390
* @param integer $timestamp when the file was deleted
390391
*/
391392
private static function retainVersions($filename, $owner, $ownerPath, $timestamp) {
392-
if (\OCP\App::isEnabled('files_versions') && !empty($ownerPath)) {
393+
if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions') && !empty($ownerPath)) {
393394
$user = OC_User::getUser();
394395
$rootView = new View('/');
395396

@@ -537,7 +538,7 @@ public static function restore($file, $filename, $timestamp) {
537538
* @return false|null
538539
*/
539540
private static function restoreVersions(View $view, $file, $filename, $uniqueFilename, $location, $timestamp) {
540-
if (\OCP\App::isEnabled('files_versions')) {
541+
if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
541542
$user = OC_User::getUser();
542543
$rootView = new View('/');
543544

@@ -698,7 +699,7 @@ public static function delete($filename, $user, $timestamp = null) {
698699
*/
699700
private static function deleteVersions(View $view, $file, $filename, $timestamp, $user) {
700701
$size = 0;
701-
if (\OCP\App::isEnabled('files_versions')) {
702+
if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
702703
if ($view->is_dir('files_trashbin/versions/' . $file)) {
703704
$size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file));
704705
$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
@@ -94,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9494
if (!$this->appManager->isEnabledForUser($app)) {
9595
continue;
9696
}
97-
$info = \OC_App::getAppInfo($app);
97+
$info = $this->appManager->getAppInfo($app);
9898
if (!is_array($info)) {
9999
continue;
100100
}

core/Command/User/ResetPassword.php

Lines changed: 7 additions & 6 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;
@@ -40,13 +41,13 @@
4041
use Symfony\Component\Console\Question\Question;
4142

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

44-
/** @var IUserManager */
45-
protected $userManager;
46-
47-
public function __construct(IUserManager $userManager) {
48-
$this->userManager = $userManager;
47+
public function __construct(IUserManager $userManager, IAppManager $appManager) {
4948
parent::__construct();
49+
$this->userManager = $userManager;
50+
$this->appManager = $appManager;
5051
}
5152

5253
protected function configure() {
@@ -86,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8687
/** @var QuestionHelper $helper */
8788
$helper = $this->getHelper('question');
8889

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

core/register_command.php

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

0 commit comments

Comments
 (0)