Skip to content

fix(DeclarativeSettings): Make declarative settings delegation aware#61864

Open
marcelklehr wants to merge 1 commit into
masterfrom
fix/allow-delegating-declarative-settings
Open

fix(DeclarativeSettings): Make declarative settings delegation aware#61864
marcelklehr wants to merge 1 commit into
masterfrom
fix/allow-delegating-declarative-settings

Conversation

@marcelklehr

Copy link
Copy Markdown
Member

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@marcelklehr marcelklehr added this to the Nextcloud 35 milestone Jul 7, 2026
@marcelklehr marcelklehr requested a review from come-nc July 7, 2026 08:10
@marcelklehr marcelklehr requested a review from a team as a code owner July 7, 2026 08:10
@marcelklehr marcelklehr added the 3. to review Waiting for reviews label Jul 7, 2026
@marcelklehr marcelklehr requested review from ArtificialOwl and salmart-dev and removed request for a team July 7, 2026 08:10
@marcelklehr marcelklehr requested a review from leftybournes July 7, 2026 08:10

@come-nc come-nc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this gives too much permissions because it’s based on section id while delegation is for each settings class.

Comment on lines +226 to +238
private function getSectionId(string $app, string $fieldId): string {
if (array_key_exists($app, $this->appSchemas)) {
foreach ($this->appSchemas[$app] as $schema) {
foreach ($schema['fields'] as $field) {
if ($field['id'] == $fieldId) {
return $schema['section_id'];
}
}
}
}

throw new Exception('Unknown fieldId "' . $fieldId . '"');
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be avoided, it’s a net loss in performance.
For getValue which is private we can add the section id to the parameters.
For setValue it may be more complicated but it’s worth trying to avoid it as well if possible. (notably if user is an admin no need to search for section id)

Comment on lines +254 to +256
* or an admin delegation covering the section: delegation is section-based, so
* being authorized for any (non-declarative) setting of the section also grants
* access to the declarative forms of that same section.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Delegation is not section-based, it’s for each settings class.

Comment on lines +58 to +60
/** @var ISettingsManager|MockObject */
private $settingsManager;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/** @var ISettingsManager|MockObject */
private $settingsManager;
private ISettingsManager&MockObject $settingsManager;

@come-nc

come-nc commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Ideally a PR for this should add delegation for a declarative settings class to give an example to test it out.
Or it should add delegation support for all declarative settings classes without changes being needed on them, if that’s possible.

@marcelklehr

Copy link
Copy Markdown
Member Author

Alright, this was just a one-shot. I don't have much more time I can spend on this. I'm happy to leave this open if somebody wants to tackle this.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants