Merge pull request #32363 from nextcloud/cleanup/remove-long-deprecated-classes

Remove OCP\App and OCP\BackgroundJob
This commit is contained in:
Carl Schwan 2022-08-08 17:05:11 +02:00 committed by GitHub
commit f8b13ecd60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 120 additions and 260 deletions

View file

@ -553,7 +553,7 @@ class File extends Node implements IFile {
* @return array|bool
*/
public function getDirectDownload() {
if (\OCP\App::isEnabled('encryption')) {
if (\OCP\Server::get(\OCP\App\IAppManager::class)->isEnabledForUser('encryption')) {
return [];
}
/** @var \OCP\Files\Storage $storage */

View file

@ -7,7 +7,7 @@
<table cellspacing="0" cellpadding="0" border="0" width="600px">
<tr>
<td colspan="2" bgcolor="<?php p($theme->getColorPrimary());?>">
<img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL(image_path('', 'logo-mail.png'))); ?>" alt="<?php p($theme->getName()); ?>"/>
<img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL(image_path('core', 'logo-mail.png'))); ?>" alt="<?php p($theme->getName()); ?>"/>
</td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>

View file

@ -35,6 +35,7 @@ use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCSController;
use OCP\App\IAppManager;
use OCP\Constants;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\Exceptions\ProviderCouldNotAddShareException;
@ -366,7 +367,7 @@ class RequestHandlerController extends OCSController {
* @return bool
*/
private function isS2SEnabled($incoming = false) {
$result = \OCP\App::isEnabled('files_sharing');
$result = \OCP\Server::get(IAppManager::class)->isEnabledForUser('files_sharing');
if ($incoming) {
$result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled();

View file

@ -54,6 +54,7 @@ use OC\Files\View;
use OCA\Files_Trashbin\AppInfo\Application;
use OCA\Files_Trashbin\Command\Expire;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\App\IAppManager;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\NotFoundException;
@ -395,7 +396,7 @@ class Trashbin {
* @param integer $timestamp when the file was deleted
*/
private static function retainVersions($filename, $owner, $ownerPath, $timestamp) {
if (\OCP\App::isEnabled('files_versions') && !empty($ownerPath)) {
if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions') && !empty($ownerPath)) {
$user = OC_User::getUser();
$rootView = new View('/');
@ -543,7 +544,7 @@ class Trashbin {
* @return false|null
*/
private static function restoreVersions(View $view, $file, $filename, $uniqueFilename, $location, $timestamp) {
if (\OCP\App::isEnabled('files_versions')) {
if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
$user = OC_User::getUser();
$rootView = new View('/');
@ -704,7 +705,7 @@ class Trashbin {
*/
private static function deleteVersions(View $view, $file, $filename, $timestamp, $user) {
$size = 0;
if (\OCP\App::isEnabled('files_versions')) {
if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
if ($view->is_dir('files_trashbin/versions/' . $file)) {
$size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file));
$view->unlink('files_trashbin/versions/' . $file);

View file

@ -67,7 +67,7 @@ class AppsControllerTest extends \OCA\Provisioning_API\Tests\TestCase {
public function testGetAppInfo() {
$result = $this->api->getAppInfo('provisioning_api');
$expected = \OC_App::getAppInfo('provisioning_api');
$expected = $this->appManager->getAppInfo('provisioning_api');
$this->assertEquals($expected, $result->getData());
}

View file

@ -4,7 +4,7 @@
</button>
<a href="<?php p(link_to_docs('admin-ldap')); ?>"
target="_blank" rel="noreferrer noopener">
<img src="<?php print_unescaped(image_path('', 'actions/info.svg')); ?>"
<img src="<?php print_unescaped(image_path('core', 'actions/info.svg')); ?>"
style="height:1.75ex" />
<?php p($l->t('Help'));?>
</a>

View file

@ -10,7 +10,7 @@
</button>
<a href="<?php p(link_to_docs('admin-ldap')); ?>"
target="_blank" rel="noreferrer noopener">
<img src="<?php print_unescaped(image_path('', 'actions/info.svg')); ?>"
<img src="<?php print_unescaped(image_path('core', 'actions/info.svg')); ?>"
style="height:1.75ex" />
<span class="ldap_grey"><?php p($l->t('Help'));?></span>
</a>

View file

@ -82,7 +82,7 @@ class Repair extends Command {
if (!$this->appManager->isEnabledForUser($app)) {
continue;
}
$info = \OC_App::getAppInfo($app);
$info = $this->appManager->getAppInfo($app);
if (!is_array($info)) {
continue;
}

View file

@ -28,6 +28,7 @@
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OCP\App\IAppManager;
use OCP\IUser;
use OCP\IUserManager;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
@ -41,10 +42,12 @@ use Symfony\Component\Console\Question\Question;
class ResetPassword extends Base {
protected IUserManager $userManager;
private IAppManager $appManager;
public function __construct(IUserManager $userManager) {
$this->userManager = $userManager;
public function __construct(IUserManager $userManager, IAppManager $appManager) {
parent::__construct();
$this->userManager = $userManager;
$this->appManager = $appManager;
}
protected function configure() {
@ -84,7 +87,7 @@ class ResetPassword extends Base {
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
if (\OCP\App::isEnabled('encryption')) {
if ($this->appManager->isEnabledForUser('encryption', $user)) {
$output->writeln(
'<error>Warning: Resetting the password when using encryption will result in data loss!</error>'
);

View file

@ -183,7 +183,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
$application->add(new OC\Core\Command\User\Enable(\OC::$server->getUserManager()));
$application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager()));
$application->add(\OC::$server->get(\OC\Core\Command\User\Report::class));
$application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager()));
$application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager(), \OC::$server->getAppManager()));
$application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig()));
$application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
$application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));

View file

@ -55,7 +55,7 @@ script('core', 'install');
<?php if (!$_['directoryIsSet'] or !$_['dbIsSet'] or count($_['errors']) > 0): ?>
<fieldset id="advancedHeader">
<legend><a id="showAdvanced" tabindex="0" href="#"><?php p($l->t('Storage & database')); ?><img src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" /></a></legend>
<legend><a id="showAdvanced" tabindex="0" href="#"><?php p($l->t('Storage & database')); ?><img src="<?php print_unescaped(image_path('core', 'actions/caret.svg')); ?>" /></a></legend>
</fieldset>
<?php endif; ?>

View file

@ -7,9 +7,9 @@
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<meta name="theme-color" content="<?php p($theme->getColorPrimary()); ?>">
<link rel="icon" href="<?php print_unescaped(image_path('', 'favicon.ico')); /* IE11+ supports png */ ?>">
<link rel="apple-touch-icon" href="<?php print_unescaped(image_path('', 'favicon-touch.png')); ?>">
<link rel="mask-icon" sizes="any" href="<?php print_unescaped(image_path('', 'favicon-mask.svg')); ?>" color="<?php p($theme->getColorPrimary()); ?>">
<link rel="icon" href="<?php print_unescaped(image_path('core', 'favicon.ico')); /* IE11+ supports png */ ?>">
<link rel="apple-touch-icon" href="<?php print_unescaped(image_path('core', 'favicon-touch.png')); ?>">
<link rel="mask-icon" sizes="any" href="<?php print_unescaped(image_path('core', 'favicon-mask.svg')); ?>" color="<?php p($theme->getColorPrimary()); ?>">
<?php emit_css_loading_tags($_); ?>
<?php emit_script_loading_tags($_); ?>
<?php print_unescaped($_['headers']); ?>

View file

@ -17,10 +17,10 @@
<meta name="apple-itunes-app" content="app-id=<?php p($theme->getiTunesAppId()); ?>">
<?php } ?>
<meta name="theme-color" content="<?php p($theme->getColorPrimary()); ?>">
<link rel="icon" href="<?php print_unescaped(image_path('', 'favicon.ico')); /* IE11+ supports png */ ?>">
<link rel="apple-touch-icon" href="<?php print_unescaped(image_path('', 'favicon-touch.png')); ?>">
<link rel="mask-icon" sizes="any" href="<?php print_unescaped(image_path('', 'favicon-mask.svg')); ?>" color="<?php p($theme->getColorPrimary()); ?>">
<link rel="manifest" href="<?php print_unescaped(image_path('', 'manifest.json')); ?>">
<link rel="icon" href="<?php print_unescaped(image_path('core', 'favicon.ico')); /* IE11+ supports png */ ?>">
<link rel="apple-touch-icon" href="<?php print_unescaped(image_path('core', 'favicon-touch.png')); ?>">
<link rel="mask-icon" sizes="any" href="<?php print_unescaped(image_path('core', 'favicon-mask.svg')); ?>" color="<?php p($theme->getColorPrimary()); ?>">
<link rel="manifest" href="<?php print_unescaped(image_path('core', 'manifest.json')); ?>">
<?php emit_css_loading_tags($_); ?>
<?php emit_script_loading_tags($_); ?>
<?php print_unescaped($_['headers']); ?>

View file

@ -21,7 +21,6 @@ return array(
'OCP\\Activity\\IManager' => $baseDir . '/lib/public/Activity/IManager.php',
'OCP\\Activity\\IProvider' => $baseDir . '/lib/public/Activity/IProvider.php',
'OCP\\Activity\\ISetting' => $baseDir . '/lib/public/Activity/ISetting.php',
'OCP\\App' => $baseDir . '/lib/public/App.php',
'OCP\\AppFramework\\ApiController' => $baseDir . '/lib/public/AppFramework/ApiController.php',
'OCP\\AppFramework\\App' => $baseDir . '/lib/public/AppFramework/App.php',
'OCP\\AppFramework\\AuthPublicShareController' => $baseDir . '/lib/public/AppFramework/AuthPublicShareController.php',
@ -110,7 +109,6 @@ return array(
'OCP\\Authentication\\TwoFactorAuth\\TwoFactorProviderForUserDisabled' => $baseDir . '/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserDisabled.php',
'OCP\\Authentication\\TwoFactorAuth\\TwoFactorProviderForUserEnabled' => $baseDir . '/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserEnabled.php',
'OCP\\AutoloadNotAllowedException' => $baseDir . '/lib/public/AutoloadNotAllowedException.php',
'OCP\\BackgroundJob' => $baseDir . '/lib/public/BackgroundJob.php',
'OCP\\BackgroundJob\\IJob' => $baseDir . '/lib/public/BackgroundJob/IJob.php',
'OCP\\BackgroundJob\\IJobList' => $baseDir . '/lib/public/BackgroundJob/IJobList.php',
'OCP\\BackgroundJob\\Job' => $baseDir . '/lib/public/BackgroundJob/Job.php',

View file

@ -54,7 +54,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Activity\\IManager' => __DIR__ . '/../../..' . '/lib/public/Activity/IManager.php',
'OCP\\Activity\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Activity/IProvider.php',
'OCP\\Activity\\ISetting' => __DIR__ . '/../../..' . '/lib/public/Activity/ISetting.php',
'OCP\\App' => __DIR__ . '/../../..' . '/lib/public/App.php',
'OCP\\AppFramework\\ApiController' => __DIR__ . '/../../..' . '/lib/public/AppFramework/ApiController.php',
'OCP\\AppFramework\\App' => __DIR__ . '/../../..' . '/lib/public/AppFramework/App.php',
'OCP\\AppFramework\\AuthPublicShareController' => __DIR__ . '/../../..' . '/lib/public/AppFramework/AuthPublicShareController.php',
@ -143,7 +142,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Authentication\\TwoFactorAuth\\TwoFactorProviderForUserDisabled' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserDisabled.php',
'OCP\\Authentication\\TwoFactorAuth\\TwoFactorProviderForUserEnabled' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserEnabled.php',
'OCP\\AutoloadNotAllowedException' => __DIR__ . '/../../..' . '/lib/public/AutoloadNotAllowedException.php',
'OCP\\BackgroundJob' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob.php',
'OCP\\BackgroundJob\\IJob' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob/IJob.php',
'OCP\\BackgroundJob\\IJobList' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob/IJobList.php',
'OCP\\BackgroundJob\\Job' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob/Job.php',

View file

@ -237,8 +237,6 @@ class App {
/**
* Shortcut for calling a controller method and printing the result.
* Similar to App:main except that no headers will be sent.
* This should be used for example when registering sections via
* \OC\AppFramework\Core\API::registerAdmin()
*
* @param string $controllerName the name of the controller under which it is
* stored in the DI container

View file

@ -34,6 +34,7 @@ use OC\MemoryInfo;
use OC\NeedsUpdateException;
use OC_App;
use OCP\AppFramework\QueryException;
use OCP\App\IAppManager;
use OCP\Console\ConsoleEvent;
use OCP\IConfig;
use OCP\IRequest;
@ -117,13 +118,14 @@ class Application {
$this->writeMaintenanceModeInfo($input, $output);
} else {
OC_App::loadApps();
foreach (\OC::$server->getAppManager()->getInstalledApps() as $app) {
$appManager = \OCP\Server::get(IAppManager::class);
foreach ($appManager->getInstalledApps() as $app) {
$appPath = \OC_App::getAppPath($app);
if ($appPath === false) {
continue;
}
// load commands using info.xml
$info = \OC_App::getAppInfo($app);
$info = $appManager->getAppInfo($app);
if (isset($info['commands'])) {
$this->loadCommandsFromInfoXml($info['commands']);
}

View file

@ -29,27 +29,22 @@ namespace OC\Encryption;
use OCP\Cache\CappedMemoryCache;
use OCA\Files_External\Service\GlobalStoragesService;
use OCP\App\IAppManager;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Share\IManager;
class File implements \OCP\Encryption\IFile {
/** @var Util */
protected $util;
/** @var IRootFolder */
private $rootFolder;
/** @var IManager */
private $shareManager;
protected Util $util;
private IRootFolder $rootFolder;
private IManager $shareManager;
/**
* cache results of already checked folders
*
* Cache results of already checked folders
* @var CappedMemoryCache<array>
*/
protected CappedMemoryCache $cache;
private ?IAppManager $appManager = null;
public function __construct(Util $util,
IRootFolder $rootFolder,
@ -60,6 +55,14 @@ class File implements \OCP\Encryption\IFile {
$this->shareManager = $shareManager;
}
public function getAppManager(): IAppManager {
// Lazy evaluate app manager as it initialize the db too early otherwise
if ($this->appManager) {
return $this->appManager;
}
$this->appManager = \OCP\Server::get(IAppManager::class);
return $this->appManager;
}
/**
* Get list of users with access to the file
@ -110,7 +113,7 @@ class File implements \OCP\Encryption\IFile {
}
// check if it is a group mount
if (\OCP\App::isEnabled("files_external")) {
if ($this->getAppManager()->isEnabledForUser("files_external")) {
/** @var GlobalStoragesService $storageService */
$storageService = \OC::$server->get(GlobalStoragesService::class);
$storages = $storageService->getAllStorages();

View file

@ -34,9 +34,12 @@ use OC\Files\Filesystem;
use OC\Files\View;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\GlobalStoragesService;
use OCP\App\IAppManager;
use OCP\Encryption\IEncryptionModule;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
class Util {
public const HEADER_START = 'HBEGIN';
@ -65,29 +68,23 @@ class Util {
/** @var array */
protected $ocHeaderKeys;
/** @var \OC\User\Manager */
protected $userManager;
/** @var IConfig */
protected $config;
/** @var array paths excluded from encryption */
protected $excludedPaths;
/** @var \OC\Group\Manager $manager */
protected $groupManager;
protected IGroupManager $groupManager;
protected IUserManager $userManager;
/**
*
* @param View $rootView
* @param \OC\User\Manager $userManager
* @param \OC\Group\Manager $groupManager
* @param IConfig $config
*/
public function __construct(
View $rootView,
\OC\User\Manager $userManager,
\OC\Group\Manager $groupManager,
IUserManager $userManager,
IGroupManager $groupManager,
IConfig $config) {
$this->ocHeaderKeys = [
self::HEADER_ENCRYPTION_MODULE_KEY
@ -275,7 +272,7 @@ class Util {
} else {
$result = array_merge($result, $users);
$groupManager = \OC::$server->getGroupManager();
$groupManager = $this->groupManager;
foreach ($groups as $group) {
$groupObject = $groupManager->get($group);
if ($groupObject) {
@ -299,7 +296,8 @@ class Util {
* @return boolean
*/
public function isSystemWideMountPoint($path, $uid) {
if (\OCP\App::isEnabled("files_external")) {
// No DI here as this initialise the db too soon
if (\OCP\Server::get(IAppManager::class)->isEnabledForUser("files_external")) {
/** @var GlobalStoragesService $storageService */
$storageService = \OC::$server->get(GlobalStoragesService::class);
$storages = $storageService->getAllStorages();
@ -377,32 +375,29 @@ class Util {
}
/**
* check if recovery key is enabled for user
*
* @param string $uid
* @return boolean
* Check if recovery key is enabled for user
*/
public function recoveryEnabled($uid) {
public function recoveryEnabled(string $uid): bool {
$enabled = $this->config->getUserValue($uid, 'encryption', 'recovery_enabled', '0');
return $enabled === '1';
}
/**
* set new key storage root
* Set new key storage root
*
* @param string $root new key store root relative to the data folder
*/
public function setKeyStorageRoot($root) {
public function setKeyStorageRoot(string $root): void {
$this->config->setAppValue('core', 'encryption_key_storage_root', $root);
}
/**
* get key storage root
* Get key storage root
*
* @return string key storage root
*/
public function getKeyStorageRoot() {
public function getKeyStorageRoot(): string {
return $this->config->getAppValue('core', 'encryption_key_storage_root', '');
}
}

View file

@ -353,7 +353,7 @@ class Server extends ServerContainer implements IServerContainer {
return new Profiler($c->get(SystemConfig::class));
});
$this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
$this->registerService(\OCP\Encryption\IManager::class, function (Server $c): Encryption\Manager {
$view = new View();
$util = new Encryption\Util(
$view,

View file

@ -42,6 +42,8 @@ namespace OC;
use OC\Route\Router;
use OCA\Theming\ThemingDefaults;
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IRequest;
@ -65,12 +67,14 @@ class URLGenerator implements IURLGenerator {
private $router;
/** @var null|string */
private $baseUrl = null;
private ?IAppManager $appManager = null;
public function __construct(IConfig $config,
IUserSession $userSession,
ICacheFactory $cacheFactory,
IRequest $request,
Router $router) {
Router $router
) {
$this->config = $config;
$this->userSession = $userSession;
$this->cacheFactory = $cacheFactory;
@ -78,6 +82,14 @@ class URLGenerator implements IURLGenerator {
$this->router = $router;
}
private function getAppManager(): IAppManager {
if ($this->appManager !== null) {
return $this->appManager;
}
$this->appManager = \OCP\Server::get(IAppManager::class);
return $this->appManager;
}
/**
* Creates an url using a defined route
*
@ -132,7 +144,7 @@ class URLGenerator implements IURLGenerator {
$frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true');
if ($appName !== '') {
$app_path = \OC_App::getAppPath($appName);
$app_path = $this->getAppManager()->getAppPath($appName);
// Check if the app is in the app folder
if ($app_path && file_exists($app_path . '/' . $file)) {
if (substr($file, -3) === 'php') {
@ -142,7 +154,7 @@ class URLGenerator implements IURLGenerator {
}
$urlLinkTo .= ($file !== 'index.php') ? '/' . $file : '';
} else {
$urlLinkTo = \OC_App::getAppWebPath($appName) . '/' . $file;
$urlLinkTo = $this->getAppManager()->getAppWebPath($appName) . '/' . $file;
}
} else {
$urlLinkTo = \OC::$WEBROOT . '/' . $appName . '/' . $file;
@ -189,11 +201,20 @@ class URLGenerator implements IURLGenerator {
//if a theme has a png but not an svg always use the png
$basename = substr(basename($file), 0, -4);
$appPath = \OC_App::getAppPath($appName);
try {
$appPath = $this->getAppManager()->getAppPath($appName);
} catch (AppPathNotFoundException $e) {
if ($appName === 'core' || $appName === '') {
$appName = 'core';
$appPath = false;
} else {
throw new RuntimeException('image not found: image: ' . $file . ' webroot: ' . \OC::$WEBROOT . ' serverroot: ' . \OC::$SERVERROOT);
}
}
// Check if the app is in the app folder
$path = '';
$themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming');
$themingEnabled = $this->config->getSystemValue('installed', false) && $this->getAppManager()->isEnabledForUser('theming');
$themingImagePath = false;
if ($themingEnabled) {
$themingDefaults = \OC::$server->getThemingDefaults();
@ -220,10 +241,10 @@ class URLGenerator implements IURLGenerator {
} elseif ($themingEnabled && $themingImagePath) {
$path = $themingImagePath;
} elseif ($appPath && file_exists($appPath . "/img/$file")) {
$path = \OC_App::getAppWebPath($appName) . "/img/$file";
$path = $this->getAppManager()->getAppWebPath($appName) . "/img/$file";
} elseif ($appPath && !file_exists($appPath . "/img/$basename.svg")
&& file_exists($appPath . "/img/$basename.png")) {
$path = \OC_App::getAppWebPath($appName) . "/img/$basename.png";
$path = $this->getAppManager()->getAppWebPath($appName) . "/img/$basename.png";
} elseif (!empty($appName) and file_exists(\OC::$SERVERROOT . "/$appName/img/$file")) {
$path = \OC::$WEBROOT . "/$appName/img/$file";
} elseif (!empty($appName) and (!file_exists(\OC::$SERVERROOT . "/$appName/img/$basename.svg")

View file

@ -378,7 +378,7 @@ class Updater extends BasicEmitter {
$appManager = \OC::$server->getAppManager();
foreach ($apps as $app) {
// check if the app is compatible with this version of Nextcloud
$info = OC_App::getAppInfo($app);
$info = $appManager->getAppInfo($app);
if ($info === null || !OC_App::isAppCompatible($version, $info)) {
if ($appManager->isShipped($app)) {
throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update');

View file

@ -678,25 +678,6 @@ class OC_App {
return $forms;
}
/**
* register an admin form to be shown
*
* @param string $app
* @param string $page
*/
public static function registerAdmin(string $app, string $page) {
self::$adminForms[] = $app . '/' . $page . '.php';
}
/**
* register a personal form to be shown
* @param string $app
* @param string $page
*/
public static function registerPersonal(string $app, string $page) {
self::$personalForms[] = $app . '/' . $page . '.php';
}
/**
* @param array $entry
* @deprecated 20.0.0 Please register your alternative login option using the registerAlternativeLogin() on the RegistrationContext in your Application class implementing the OCP\Authentication\IAlternativeLogin interface

View file

@ -1,104 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Bart Visscher <bartv@thisnet.nl>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Frank Karlitschek <frank@karlitschek.de>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Julius Härtl <jus@bitgrid.net>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin McCorkell <robin@mccorkell.me.uk>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP;
/**
* This class provides functions to manage apps in ownCloud
* @since 4.0.0
* @deprecated 14.0.0
*/
class App {
/**
* Register a Configuration Screen that should appear in the personal settings section.
* @param string $app appid
* @param string $page page to be included
* @return void
* @since 4.0.0
* @deprecated 14.0.0 Use settings section in appinfo.xml to register personal admin sections
*/
public static function registerPersonal($app, $page) {
\OC_App::registerPersonal($app, $page);
}
/**
* Register a Configuration Screen that should appear in the Admin section.
* @param string $app string appid
* @param string $page string page to be included
* @return void
* @since 4.0.0
* @deprecated 14.0.0 Use settings section in appinfo.xml to register admin sections
*/
public static function registerAdmin($app, $page) {
\OC_App::registerAdmin($app, $page);
}
/**
* Read app metadata from the info.xml file
* @param string $app id of the app or the path of the info.xml file
* @param boolean $path (optional)
* @return array|null
* @deprecated 14.0.0 ise \OC::$server->getAppManager()->getAppInfo($appId)
* @since 4.0.0
*/
public static function getAppInfo($app, $path = false) {
return \OC_App::getAppInfo($app, $path);
}
/**
* checks whether or not an app is enabled
* @param string $app
* @return boolean
*
* This function checks whether or not an app is enabled.
* @since 4.0.0
* @deprecated 13.0.0 use \OC::$server->getAppManager()->isEnabledForUser($appId)
*/
public static function isEnabled($app) {
return \OC::$server->getAppManager()->isEnabledForUser($app);
}
/**
* Get the last version of the app from appinfo/info.xml
* @param string $app
* @return string
* @since 4.0.0
* @deprecated 14.0.0 use \OC::$server->getAppManager()->getAppVersion($appId)
*/
public static function getAppVersion($app) {
return \OC::$server->getAppManager()->getAppVersion($app);
}
}

View file

@ -36,6 +36,9 @@ use OCP\IUser;
/**
* Interface IAppManager
*
* @warning This interface shouldn't be included with dependency injection in
* classes used for installing Nextcloud.
*
* @since 8.0.0
*/
interface IAppManager {

View file

@ -1,45 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Jakob Sack <mail@jakobsack.de>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP;
/**
* @since 4.5.0
* @deprecated 14.0.0
*/
class BackgroundJob {
/**
* @since 5.0.0
* @deprecated 14.0.0
*/
public static function getExecutionType() {
return '';
}
/**
* @since 5.0.0
* @deprecated 14.0.0
*/
public static function setExecutionType($type) {
}
}

View file

@ -8,6 +8,8 @@ use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\GlobalStoragesService;
use OCP\Encryption\IEncryptionModule;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IUserManager;
use Test\TestCase;
class UtilTest extends TestCase {
@ -15,24 +17,21 @@ class UtilTest extends TestCase {
/**
* block size will always be 8192 for a PHP stream
* @see https://bugs.php.net/bug.php?id=21641
* @var integer
*/
protected $headerSize = 8192;
protected int $headerSize = 8192;
/** @var \PHPUnit\Framework\MockObject\MockObject */
protected $view;
/** @var \PHPUnit\Framework\MockObject\MockObject */
/** @var \PHPUnit\Framework\MockObject\MockObject|IUserManager */
protected $userManager;
/** @var \PHPUnit\Framework\MockObject\MockObject */
/** @var \PHPUnit\Framework\MockObject\MockObject|IGroupManager */
protected $groupManager;
/** @var \PHPUnit\Framework\MockObject\MockObject */
/** @var \PHPUnit\Framework\MockObject\MockObject|IConfig */
private $config;
/** @var \OC\Encryption\Util */
private $util;
private Util $util;
protected function setUp(): void {
parent::setUp();
@ -40,17 +39,9 @@ class UtilTest extends TestCase {
->disableOriginalConstructor()
->getMock();
$this->userManager = $this->getMockBuilder('OC\User\Manager')
->disableOriginalConstructor()
->getMock();
$this->groupManager = $this->getMockBuilder('OC\Group\Manager')
->disableOriginalConstructor()
->getMock();
$this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->config = $this->createMock(IConfig::class);
$this->util = new Util(
$this->view,

View file

@ -297,7 +297,7 @@ class UrlGeneratorTest extends \Test\TestCase {
$this->assertEquals('http://localhost' . \OC::$WEBROOT . $expectedPath, $this->urlGenerator->linkToDefaultPageUrl());
}
public function provideDefaultApps() {
public function provideDefaultApps(): array {
return [
// none specified, default to files
[
@ -321,4 +321,18 @@ class UrlGeneratorTest extends \Test\TestCase {
],
];
}
public function imagePathProvider(): array {
return [
['core', 'favicon-mask.svg', \OC::$WEBROOT . '/core/img/favicon-mask.svg'],
['files', 'external.svg', \OC::$WEBROOT . '/apps/files/img/external.svg'],
];
}
/**
* @dataProvider imagePathProvider
*/
public function testImagePath(string $appName, string $file, string $result): void {
$this->assertSame($result, $this->urlGenerator->imagePath($appName, $file));
}
}