Skip to content

DI of OCP\Files\Folder fails for guests #11184

Description

@nickvergessen

E.g.

TypeError
Argument 4 passed to OCA\Comments\Controller\Notifications::__construct() must implement interface OCP\Files\Folder, null given

The problem is, that the UserFolder is returned as null instead of something like e.g. NonExistingFolder

$this->registerService(IAppData::class, function (SimpleContainer $c) {
return $this->getServer()->getAppDataDir($c->query('AppName'));
});

So either all apps which use Folder injection need to allow = null manually or they will throw if one of the roots is invoked by a guest.

@icewind1991 do you think NonExistingFolder would make sense, or should we just advice all consumers of the app to explicitly allow null or inject IRootFolder instead and get the folder once they are sure it's a logged in user.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions