Error 500 on share api
Explain the Problem
I'm trying to integrate the module https://www.drupal.org/project/nextcloud_dam that use webapppassword and share api /apps/webapppassword/api/v1/shares. The result during preflight OPTIONS is a consistent error 500 from NextCloud server.
System Information
WebAppPassword app version: 25.8.0
Nextcloud version: 31.0.8
Nextcloud error
Error: OCA\Files_Sharing\Controller\ShareAPIController::__construct(): Argument #18 ($tagManager) must be of type OCP\ITagManager, string given,
called in /xxxxxxx/public_html/apps/webapppassword/lib/Controller/ShareAPIController.php on line 75
OPTIONS /index.php/apps/webapppassword/api/v1/shares
Looking to the server source, the commit https://github.com/nextcloud/server/commit/dea8324912e1375405df593ee34ef852b99a6877 change the constructor parameters and from this the mismatch.
/**
* Share20OCS constructor.
*/
public function __construct(
string $appName,
IRequest $request,
private IManager $shareManager,
private IGroupManager $groupManager,
private IUserManager $userManager,
private IRootFolder $rootFolder,
private IURLGenerator $urlGenerator,
private IL10N $l,
private IConfig $config,
private IAppManager $appManager,
private ContainerInterface $serverContainer,
private IUserStatusManager $userStatusManager,
private IPreview $previewManager,
private IDateTimeZone $dateTimeZone,
private LoggerInterface $logger,
private IProviderFactory $factory,
private IMailer $mailer,
+ private ITagManager $tagManager,
+ private ?TrustedServers $trustedServers,
private ?string $userId = null,
)
Also, other changes in parameters are in NextCloud 32 :-(
/**
* Share20OCS constructor.
*/
public function __construct(
string $appName,
IRequest $request,
private IManager $shareManager,
private IGroupManager $groupManager,
private IUserManager $userManager,
private IRootFolder $rootFolder,
private IURLGenerator $urlGenerator,
private IL10N $l,
private IConfig $config,
+ private IAppConfig $appConfig,
private IAppManager $appManager,
private ContainerInterface $serverContainer,
private IUserStatusManager $userStatusManager,
private IPreview $previewManager,
private IDateTimeZone $dateTimeZone,
private LoggerInterface $logger,
private IProviderFactory $factory,
private IMailer $mailer,
private ITagManager $tagManager,
private ?TrustedServers $trustedServers,
private ?string $userId = null,
)
@aleixq, any ideas?
I'll take a look asap
(⏳ I am creating the unit test to automatically detect it whenever it happens...So still wip, while not there, if it is superimportant to make it work, although I didn't check it, changing the arguments might make it work)
31.0.8 introduced ITagManager and TrustedServer in the ShareApiController, which is why calling parent::constructor fails. I have a fix already. I'll provide a PR after testing it on all prior relevant versions, as before.
Yes, that's it. I cretaed a simple test to check it in another pr, waiting for @pbek review, as soon as it is merged it will be great if pr with constructor changes can pass the test to make things easier as soon as new nextcloud release is out.
I cretaed a simple test to check it in another pr, waiting for @pbek review,
That one https://github.com/digital-blueprint/webapppassword/pull/296? It fails all tests...
I was completely wrong about the test, I didn't remember that constructor will be always different as we added a lot of services to the constructor to comply with multiple nextcloud versions... So I need to go deeper in the tests...
Anyway, while not here, I rethinked the share api controller to be more future-proof, to be lighter, and to be less vulnerable to parent constructor changes, so not being so opinionated. The way how I refactored the parent constructor call was picking the way how simplecontainer in nextcloud is fetching the constructor parameters to carry on the DI. While not creating phpunit tests, it will be great that some adopters of webappassword share api to test if The PR https://github.com/digital-blueprint/webapppassword/pull/297 can solve the version issues we faced.
This must be fixed with the PR https://github.com/digital-blueprint/webapppassword/pull/299 . to be more future proof, check it out https://github.com/digital-blueprint/webapppassword/pull/300