Skip to content

Commit

Permalink
load apps after install, befor user auto-login
Browse files Browse the repository at this point in the history
- otherwise apps are not registered properly
- dependency issues may throw exceptions
- Remove profile manager from public API
- Some cleanup of unused code
- Add @SInCE for new properties

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz authored and Pytal committed Oct 18, 2021
1 parent 4ebb61e commit 870b218
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 189 deletions.
6 changes: 3 additions & 3 deletions apps/settings/lib/Settings/Personal/PersonalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
use OCP\IUser;
use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\Profile\IProfileManager;
use OC\Profile\ProfileManager;
use OCP\Settings\ISettings;

class PersonalInfo implements ISettings {
Expand All @@ -66,7 +66,7 @@ class PersonalInfo implements ISettings {
/** @var IAccountManager */
private $accountManager;

/** @var IProfileManager */
/** @var ProfileManager */
private $profileManager;

/** @var IGroupManager */
Expand All @@ -89,7 +89,7 @@ public function __construct(
IUserManager $userManager,
IGroupManager $groupManager,
IAccountManager $accountManager,
IProfileManager $profileManager,
ProfileManager $profileManager,
IAppManager $appManager,
IFactory $l10nFactory,
IL10N $l,
Expand Down
6 changes: 3 additions & 3 deletions core/Controller/ProfileApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
use OCP\IRequest;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Profile\IProfileManager;
use OC\Profile\ProfileManager;

class ProfileApiController extends OCSController {

/** @var ProfileConfigMapper */
private $configMapper;

/** @var IProfileManager */
/** @var ProfileManager */
private $profileManager;

/** @var IUserManager */
Expand All @@ -54,7 +54,7 @@ class ProfileApiController extends OCSController {
public function __construct(
IRequest $request,
ProfileConfigMapper $configMapper,
IProfileManager $profileManager,
ProfileManager $profileManager,
IUserManager $userManager,
IUserSession $userSession
) {
Expand Down
6 changes: 3 additions & 3 deletions core/Controller/ProfilePageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
use OCP\IRequest;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Profile\IProfileManager;
use OC\Profile\ProfileManager;
use OCP\UserStatus\IManager as IUserStatusManager;

class ProfilePageController extends Controller {
Expand All @@ -45,7 +45,7 @@ class ProfilePageController extends Controller {
/** @var IAccountManager */
private $accountManager;

/** @var IProfileManager */
/** @var ProfileManager */
private $profileManager;

/** @var IUserManager */
Expand All @@ -62,7 +62,7 @@ public function __construct(
IRequest $request,
IInitialState $initialStateService,
IAccountManager $accountManager,
IProfileManager $profileManager,
ProfileManager $profileManager,
IUserManager $userManager,
IUserSession $userSession,
IUserStatusManager $userStatusManager
Expand Down
8 changes: 0 additions & 8 deletions core/Db/ProfileConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ class ProfileConfig extends Entity implements JsonSerializable {
IAccountManager::PROPERTY_HEADLINE => self::VISIBILITY_SHOW,
IAccountManager::PROPERTY_ORGANISATION => self::VISIBILITY_SHOW,
IAccountManager::PROPERTY_ROLE => self::VISIBILITY_SHOW,
];

/**
* Default account property action visibility
*
* @since 23.0.0
*/
public const DEFAULT_PROPERTY_ACTION_VISIBILITY = [
IAccountManager::PROPERTY_EMAIL => self::VISIBILITY_SHOW_USERS_ONLY,
IAccountManager::PROPERTY_PHONE => self::VISIBILITY_SHOW_USERS_ONLY,
IAccountManager::PROPERTY_TWITTER => self::VISIBILITY_SHOW,
Expand Down
1 change: 0 additions & 1 deletion lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@
'OCP\\Preview\\IProviderV2' => $baseDir . '/lib/public/Preview/IProviderV2.php',
'OCP\\Preview\\IVersionedPreviewFile' => $baseDir . '/lib/public/Preview/IVersionedPreviewFile.php',
'OCP\\Profile\\ILinkAction' => $baseDir . '/lib/public/Profile/ILinkAction.php',
'OCP\\Profile\\IProfileManager' => $baseDir . '/lib/public/Profile/IProfileManager.php',
'OCP\\Profile\\ParameterDoesNotExistException' => $baseDir . '/lib/public/Profile/ParameterDoesNotExistException.php',
'OCP\\Remote\\Api\\IApiCollection' => $baseDir . '/lib/public/Remote/Api/IApiCollection.php',
'OCP\\Remote\\Api\\IApiFactory' => $baseDir . '/lib/public/Remote/Api/IApiFactory.php',
Expand Down
1 change: 0 additions & 1 deletion lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\Preview\\IProviderV2' => __DIR__ . '/../../..' . '/lib/public/Preview/IProviderV2.php',
'OCP\\Preview\\IVersionedPreviewFile' => __DIR__ . '/../../..' . '/lib/public/Preview/IVersionedPreviewFile.php',
'OCP\\Profile\\ILinkAction' => __DIR__ . '/../../..' . '/lib/public/Profile/ILinkAction.php',
'OCP\\Profile\\IProfileManager' => __DIR__ . '/../../..' . '/lib/public/Profile/IProfileManager.php',
'OCP\\Profile\\ParameterDoesNotExistException' => __DIR__ . '/../../..' . '/lib/public/Profile/ParameterDoesNotExistException.php',
'OCP\\Remote\\Api\\IApiCollection' => __DIR__ . '/../../..' . '/lib/public/Remote/Api/IApiCollection.php',
'OCP\\Remote\\Api\\IApiFactory' => __DIR__ . '/../../..' . '/lib/public/Remote/Api/IApiFactory.php',
Expand Down
1 change: 1 addition & 0 deletions lib/private/Accounts/AccountManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ protected function buildDefaultUserRecord(IUser $user) {
[
'name' => self::PROPERTY_PROFILE_ENABLED,
'value' => '1',
'scope' => self::SCOPE_LOCAL,
],
];
}
Expand Down
7 changes: 0 additions & 7 deletions lib/private/AppFramework/Bootstrap/Coordinator.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
use OCP\Dashboard\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IServerContainer;
use OCP\Profile\IProfileManager;
use Psr\Log\LoggerInterface;
use Throwable;

Expand All @@ -56,9 +55,6 @@ class Coordinator {
/** @var IManager */
private $dashboardManager;

/** @var IProfileManager */
private $profileManager;

/** @var IEventDispatcher */
private $eventDispatcher;

Expand All @@ -75,14 +71,12 @@ public function __construct(
IServerContainer $container,
Registry $registry,
IManager $dashboardManager,
IProfileManager $profileManager,
IEventDispatcher $eventListener,
LoggerInterface $logger
) {
$this->serverContainer = $container;
$this->registry = $registry;
$this->dashboardManager = $dashboardManager;
$this->profileManager = $profileManager;
$this->eventDispatcher = $eventListener;
$this->logger = $logger;
}
Expand Down Expand Up @@ -150,7 +144,6 @@ private function registerApps(array $appIds): void {
$this->registrationContext->delegateCapabilityRegistrations($apps);
$this->registrationContext->delegateCrashReporterRegistrations($apps, $this->registry);
$this->registrationContext->delegateDashboardPanelRegistrations($apps, $this->dashboardManager);
$this->registrationContext->delegateProfileActionRegistrations($apps, $this->profileManager);
$this->registrationContext->delegateEventListenerRegistrations($this->eventDispatcher);
$this->registrationContext->delegateContainerRegistrations($apps);
$this->registrationContext->delegateMiddlewareRegistrations($apps);
Expand Down
52 changes: 21 additions & 31 deletions lib/private/AppFramework/Bootstrap/RegistrationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
use OCP\Http\WellKnown\IHandler;
use OCP\Notification\INotifier;
use OCP\Profile\ILinkAction;
use OCP\Profile\IProfileManager;
use OCP\Search\IProvider;
use OCP\Support\CrashReport\IReporter;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -146,13 +145,6 @@ public function registerDashboardWidget(string $widgetClass): void {
);
}

public function registerProfileAction(string $actionClass): void {
$this->context->registerProfileAction(
$this->appId,
$actionClass
);
}

public function registerService(string $name, callable $factory, bool $shared = true): void {
$this->context->registerService(
$this->appId,
Expand Down Expand Up @@ -249,6 +241,13 @@ public function registerCalendarProvider(string $class): void {
$class
);
}

public function registerProfileAction(string $actionClass): void {
$this->context->registerProfileAction(
$this->appId,
$actionClass
);
}
};
}

Expand All @@ -273,13 +272,6 @@ public function registerDashboardPanel(string $appId, string $panelClass): void
$this->dashboardPanels[] = new ServiceRegistration($appId, $panelClass);
}

/**
* @psalm-param class-string<ILinkAction> $capability
*/
public function registerProfileAction(string $appId, string $actionClass): void {
$this->profileActions[] = new ServiceRegistration($appId, $actionClass);
}

public function registerService(string $appId, string $name, callable $factory, bool $shared = true): void {
$this->services[] = new ServiceFactoryRegistration($appId, $name, $factory, $shared);
}
Expand Down Expand Up @@ -335,6 +327,13 @@ public function registerCalendarProvider(string $appId, string $class): void {
$this->calendarProviders[] = new ServiceRegistration($appId, $class);
}

/**
* @psalm-param class-string<ILinkAction> $capability
*/
public function registerProfileAction(string $appId, string $actionClass): void {
$this->profileActions[] = new ServiceRegistration($appId, $actionClass);
}

/**
* @param App[] $apps
*/
Expand Down Expand Up @@ -393,22 +392,6 @@ public function delegateDashboardPanelRegistrations(array $apps, IManager $dashb
}
}

/**
* @param App[] $apps
*/
public function delegateProfileActionRegistrations(array $apps, IProfileManager $profileManager): void {
while (($action = array_shift($this->profileActions)) !== null) {
try {
$profileManager->queueAction($action->getService());
} catch (Throwable $e) {
$appId = $action->getAppId();
$this->logger->error("Error during queuing of profile action for $appId: " . $e->getMessage(), [
'exception' => $e,
]);
}
}
}

public function delegateEventListenerRegistrations(IEventDispatcher $eventDispatcher): void {
while (($registration = array_shift($this->eventListeners)) !== null) {
try {
Expand Down Expand Up @@ -588,4 +571,11 @@ public function getTwoFactorProviders(): array {
public function getCalendarProviders(): array {
return $this->calendarProviders;
}

/**
* @return ServiceRegistration<ILinkAction>[]
*/
public function getProfileActions(): array {
return $this->profileActions;
}
}
Loading

0 comments on commit 870b218

Please sign in to comment.