fix: Remove support for app.php loading

It has been deprecated for a long time, and the last known active
 application to use it (user_saml) is now migrated the modern API.
Presence of the file is still checked in order to log an error.
This behavior may be removed as well in a few versions.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/52178/head
Côme Chilliet 6 months ago
parent 988da9622c
commit 92038229fa
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
  1. 51
      lib/private/App/AppManager.php
  2. 4
      lib/private/AppFramework/Bootstrap/Coordinator.php
  3. 2
      lib/public/AppFramework/Bootstrap/IBootstrap.php

@ -8,7 +8,6 @@ namespace OC\App;
use OC\AppConfig;
use OC\AppFramework\Bootstrap\Coordinator;
use OC\ServerNotAvailableException;
use OCP\Activity\IManager as IActivityManager;
use OCP\App\AppPathNotFoundException;
use OCP\App\Events\AppDisableEvent;
@ -251,7 +250,7 @@ class AppManager implements IAppManager {
}
}
// prevent app.php from printing output
// prevent app loading from printing output
ob_start();
foreach ($apps as $app) {
if (!$this->isAppLoaded($app) && ($types === [] || $this->isType($app, $types))) {
@ -452,43 +451,13 @@ class AppManager implements IAppManager {
// in case someone calls loadApp() directly
\OC_App::registerAutoloading($app, $appPath);
/** @var Coordinator $coordinator */
$coordinator = \OC::$server->get(Coordinator::class);
$isBootable = $coordinator->isBootable($app);
$hasAppPhpFile = is_file($appPath . '/appinfo/app.php');
if ($isBootable && $hasAppPhpFile) {
$this->logger->error('/appinfo/app.php is not loaded when \OCP\AppFramework\Bootstrap\IBootstrap on the application class is used. Migrate everything from app.php to the Application class.', [
if (is_file($appPath . '/appinfo/app.php')) {
$this->logger->error('/appinfo/app.php is not supported anymore, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.', [
'app' => $app,
]);
} elseif ($hasAppPhpFile) {
$eventLogger->start("bootstrap:load_app:$app:app.php", "Load legacy app.php app $app");
$this->logger->debug('/appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.', [
'app' => $app,
]);
try {
self::requireAppFile($appPath);
} catch (\Throwable $ex) {
if ($ex instanceof ServerNotAvailableException) {
throw $ex;
}
if (!$this->isShipped($app) && !$this->isType($app, ['authentication'])) {
$this->logger->error("App $app threw an error during app.php load and will be disabled: " . $ex->getMessage(), [
'exception' => $ex,
]);
// Only disable apps which are not shipped and that are not authentication apps
$this->disableApp($app, true);
} else {
$this->logger->error("App $app threw an error during app.php load: " . $ex->getMessage(), [
'exception' => $ex,
]);
}
}
$eventLogger->end("bootstrap:load_app:$app:app.php");
}
$coordinator = \OCP\Server::get(Coordinator::class);
$coordinator->bootApp($app);
$eventLogger->start("bootstrap:load_app:$app:info", "Load info.xml for $app and register any services defined in it");
@ -560,6 +529,7 @@ class AppManager implements IAppManager {
$eventLogger->end("bootstrap:load_app:$app");
}
/**
* Check if an app is loaded
* @param string $app app id
@ -569,17 +539,6 @@ class AppManager implements IAppManager {
return isset($this->loadedApps[$app]);
}
/**
* Load app.php from the given app
*
* @param string $app app name
* @throws \Error
*/
private static function requireAppFile(string $app): void {
// encapsulated here to avoid variable scope conflicts
require_once $app . '/appinfo/app.php';
}
/**
* Enable an app for every user
*

@ -30,8 +30,8 @@ class Coordinator {
/** @var RegistrationContext|null */
private $registrationContext;
/** @var string[] */
private $bootedApps = [];
/** @var array<string,true> */
private array $bootedApps = [];
public function __construct(
private IServerContainer $serverContainer,

@ -25,8 +25,6 @@ interface IBootstrap {
* At this stage you can assume that all services are registered and the DI
* container(s) are ready to be queried.
*
* This is also the state where an optional `appinfo/app.php` was loaded.
*
* @param IBootContext $context
*
* @since 20.0.0

Loading…
Cancel
Save