Skip to content

Commit fb72441

Browse files
authored
Merge pull request #52178 from nextcloud/fix/remove-app.php-loading
fix: Remove support for app.php loading
2 parents 47f1950 + 12b1342 commit fb72441

4 files changed

Lines changed: 7 additions & 55 deletions

File tree

build/psalm-baseline.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,11 +1324,6 @@
13241324
<code><![CDATA[$this->fastCache[$app][$key] ?? $default]]></code>
13251325
</NullableReturnStatement>
13261326
</file>
1327-
<file src="lib/private/AppFramework/Bootstrap/Coordinator.php">
1328-
<InvalidPropertyAssignmentValue>
1329-
<code><![CDATA[$this->bootedApps]]></code>
1330-
</InvalidPropertyAssignmentValue>
1331-
</file>
13321327
<file src="lib/private/AppFramework/Bootstrap/FunctionInjector.php">
13331328
<UndefinedMethod>
13341329
<code><![CDATA[getName]]></code>

lib/private/App/AppManager.php

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
use OC\AppConfig;
1010
use OC\AppFramework\Bootstrap\Coordinator;
11-
use OC\ServerNotAvailableException;
1211
use OCP\Activity\IManager as IActivityManager;
1312
use OCP\App\AppPathNotFoundException;
1413
use OCP\App\Events\AppDisableEvent;
@@ -251,7 +250,7 @@ public function loadApps(array $types = []): bool {
251250
}
252251
}
253252

254-
// prevent app.php from printing output
253+
// prevent app loading from printing output
255254
ob_start();
256255
foreach ($apps as $app) {
257256
if (!$this->isAppLoaded($app) && ($types === [] || $this->isType($app, $types))) {
@@ -452,43 +451,13 @@ public function loadApp(string $app): void {
452451
// in case someone calls loadApp() directly
453452
\OC_App::registerAutoloading($app, $appPath);
454453

455-
/** @var Coordinator $coordinator */
456-
$coordinator = \OC::$server->get(Coordinator::class);
457-
$isBootable = $coordinator->isBootable($app);
458-
459-
$hasAppPhpFile = is_file($appPath . '/appinfo/app.php');
460-
461-
if ($isBootable && $hasAppPhpFile) {
462-
$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.', [
454+
if (is_file($appPath . '/appinfo/app.php')) {
455+
$this->logger->error('/appinfo/app.php is not supported anymore, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.', [
463456
'app' => $app,
464457
]);
465-
} elseif ($hasAppPhpFile) {
466-
$eventLogger->start("bootstrap:load_app:$app:app.php", "Load legacy app.php app $app");
467-
$this->logger->debug('/appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.', [
468-
'app' => $app,
469-
]);
470-
try {
471-
self::requireAppFile($appPath);
472-
} catch (\Throwable $ex) {
473-
if ($ex instanceof ServerNotAvailableException) {
474-
throw $ex;
475-
}
476-
if (!$this->isShipped($app) && !$this->isType($app, ['authentication'])) {
477-
$this->logger->error("App $app threw an error during app.php load and will be disabled: " . $ex->getMessage(), [
478-
'exception' => $ex,
479-
]);
480-
481-
// Only disable apps which are not shipped and that are not authentication apps
482-
$this->disableApp($app, true);
483-
} else {
484-
$this->logger->error("App $app threw an error during app.php load: " . $ex->getMessage(), [
485-
'exception' => $ex,
486-
]);
487-
}
488-
}
489-
$eventLogger->end("bootstrap:load_app:$app:app.php");
490458
}
491459

460+
$coordinator = \OCP\Server::get(Coordinator::class);
492461
$coordinator->bootApp($app);
493462

494463
$eventLogger->start("bootstrap:load_app:$app:info", "Load info.xml for $app and register any services defined in it");
@@ -560,6 +529,7 @@ public function loadApp(string $app): void {
560529

561530
$eventLogger->end("bootstrap:load_app:$app");
562531
}
532+
563533
/**
564534
* Check if an app is loaded
565535
* @param string $app app id
@@ -569,17 +539,6 @@ public function isAppLoaded(string $app): bool {
569539
return isset($this->loadedApps[$app]);
570540
}
571541

572-
/**
573-
* Load app.php from the given app
574-
*
575-
* @param string $app app name
576-
* @throws \Error
577-
*/
578-
private static function requireAppFile(string $app): void {
579-
// encapsulated here to avoid variable scope conflicts
580-
require_once $app . '/appinfo/app.php';
581-
}
582-
583542
/**
584543
* Enable an app for every user
585544
*

lib/private/AppFramework/Bootstrap/Coordinator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class Coordinator {
3030
/** @var RegistrationContext|null */
3131
private $registrationContext;
3232

33-
/** @var string[] */
34-
private $bootedApps = [];
33+
/** @var array<string,true> */
34+
private array $bootedApps = [];
3535

3636
public function __construct(
3737
private IServerContainer $serverContainer,

lib/public/AppFramework/Bootstrap/IBootstrap.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public function register(IRegistrationContext $context): void;
2525
* At this stage you can assume that all services are registered and the DI
2626
* container(s) are ready to be queried.
2727
*
28-
* This is also the state where an optional `appinfo/app.php` was loaded.
29-
*
3028
* @param IBootContext $context
3129
*
3230
* @since 20.0.0

0 commit comments

Comments
 (0)