Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add notes path to capabilities #1468

Merged
merged 5 commits into from
Feb 17, 2025
Merged

add notes path to capabilities #1468

merged 5 commits into from
Feb 17, 2025

Conversation

tobiasKaminsky
Copy link
Member

No description provided.

@tobiasKaminsky
Copy link
Member Author

@juliusknorr thanks! Tested & works!

@enjeck
Copy link
Contributor

enjeck commented Feb 1, 2025

@tobiasKaminsky Some CI tests are failing

@tobiasKaminsky tobiasKaminsky force-pushed the notesFolderToCapability branch 2 times, most recently from 8113c57 to e095095 Compare February 4, 2025 09:30
@tobiasKaminsky
Copy link
Member Author

@juliusknorr or @enjeck can you help me with psalm?

ERROR: RiskyTruthyFalsyComparison
at /home/tobi/github/nextcloud/notes/lib/AppInfo/Capabilities.php:29:21
Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
                                'notes_path' => $this->userId ? $this->noteUtil->getNotesFolderUserPath($this->userId) : null,

Not sure what to do.

@enjeck
Copy link
Contributor

enjeck commented Feb 4, 2025

I haven't looked deeply yet, but my first thought is that maybe the warning is about $this->userId which could be null or the empty string, and both cases are falsy. So maybe changing to $this->userId !== null && $this->userId !== " "? $this->noteUtil->getNotesFolderUserPath($this->userId) : null

@enjeck
Copy link
Contributor

enjeck commented Feb 4, 2025

There seem to be other unrelated CI failures like the test-api (min). I can look into that

@tobiasKaminsky tobiasKaminsky force-pushed the notesFolderToCapability branch from e095095 to 691e455 Compare February 5, 2025 06:56
@tobiasKaminsky
Copy link
Member Author

@juliusknorr I am sorry, but I give up on this.
I am not familar with it, and having two lines of code changes, killing the entire CI… 🤷

@enjeck enjeck force-pushed the notesFolderToCapability branch from 777613d to a2ebf0a Compare February 17, 2025 07:00
@enjeck
Copy link
Contributor

enjeck commented Feb 17, 2025

@tobiasKaminsky At 3b41954, you moved nextcloud/ocp from dev-stable28 to dev-master. I believe that's not required for this PR, so I reverted that in case it was causing some of the CI failures. I can move to dev-master in a separate PR if needed.

@enjeck enjeck merged commit 15c2df6 into main Feb 17, 2025
30 checks passed
@enjeck enjeck deleted the notesFolderToCapability branch February 17, 2025 07:58
@enjeck
Copy link
Contributor

enjeck commented Feb 17, 2025

Actually, when I test this out, I get an error on the homepage:

Internal Server Error
The server was unable to complete your request.

If this happens again, please send the technical details below to the server administrator.

More details can be found in the server log.

Technical details
Remote Address: 192.168.21.4
Request ID: 1b5EZixWS2bZK7VIVCVm
Type: OCA\Notes\Service\NotesFolderException
Code: 0
Message: Notes is not a folder
File: /var/www/html/apps/notes/lib/Service/NoteUtil.php
Line: 213

Trace
#0 /var/www/html/apps/notes/lib/Service/NoteUtil.php(189): OCA\Notes\Service\NoteUtil->getOrCreateNotesFolder('admin', false)
#1 /var/www/html/apps/notes/lib/AppInfo/Capabilities.php(29): OCA\Notes\Service\NoteUtil->getNotesFolderUserPath('admin')
#2 /var/www/html/lib/private/CapabilitiesManager.php(61): OCA\Notes\AppInfo\Capabilities->getCapabilities()
#3 /var/www/html/lib/private/Template/JSConfigHelper.php(137): OC\CapabilitiesManager->getCapabilities(false, true)
#4 /var/www/html/lib/private/TemplateLayout.php(239): OC\Template\JSConfigHelper->getConfig()
#5 /var/www/html/lib/private/legacy/OC_Template.php(120): OC\TemplateLayout->__construct('user', 'dashboard')
#6 /var/www/html/lib/public/AppFramework/Http/TemplateResponse.php(189): OC_Template->fetchPage(Array)
#7 /var/www/html/lib/private/AppFramework/Http/Dispatcher.php(159): OCP\AppFramework\Http\TemplateResponse->render()
#8 /var/www/html/lib/private/AppFramework/App.php(161): OC\AppFramework\Http\Dispatcher->dispatch(Object(OCA\Dashboard\Controller\DashboardController), 'index')
#9 /var/www/html/lib/private/Route/Router.php(306): OC\AppFramework\App::main('OCA\\Dashboard\\C...', 'index', Object(OC\AppFramework\DependencyInjection\DIContainer), Array)
#10 /var/www/html/lib/base.php(1018): OC\Route\Router->match('/apps/dashboard...')
#11 /var/www/html/index.php(24): OC::handleRequest()
#12 {main}

Probably shouldn't have merged yet???

@enjeck
Copy link
Contributor

enjeck commented Feb 17, 2025

@tobiasKaminsky At 3b41954, you moved nextcloud/ocp from dev-stable28 to dev-master. I believe that's not required for this PR, so I reverted that in case it was causing some of the CI failures. I can move to dev-master in a separate PR if needed.

I suspect that 3b41954 is essential and I shouldn't have removed it 🤦

@enjeck
Copy link
Contributor

enjeck commented Feb 17, 2025

I tried using dev-master (which required going from php 8.0 to 8.1) but that didn't help

public function getNotesFolderUserPath(string $userId): ?string {
/** @psalm-suppress MissingDependency */
$userFolder = $this->getRoot()->getUserFolder($userId);
$nodesFolder = $this->getOrCreateNotesFolder($userId, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably on users where the folder does not exists yet (e.g. new users on first login).
Possible solutions: either the create parameter has to be true, or the NotesFolderException has to be caught.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An integration test would have caught this btw.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even a frontend test would have caught this too, since this error crashes the entire server 🤦

@enjeck enjeck mentioned this pull request Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants