Fix - Loss of profile rights when updating the plugin#348
Open
RomainLvr wants to merge 5 commits into10.0/bugfixesfrom
Open
Fix - Loss of profile rights when updating the plugin#348RomainLvr wants to merge 5 commits into10.0/bugfixesfrom
RomainLvr wants to merge 5 commits into10.0/bugfixesfrom
Conversation
Rom1-B
requested changes
Feb 12, 2026
Comment on lines
101
to
116
| /** @var \DBmysql $DB */ | ||
| global $DB; | ||
|
|
||
| $query = [ | ||
| 'FROM' => $this->getTable(), | ||
| 'WHERE' => [ | ||
| 'profiles_id' => $profiles_id, | ||
| ], | ||
| ]; | ||
| $result = $DB->request($query); | ||
| if ($result->numrows() != 1) { | ||
| if (empty($result->numrows())) { | ||
| return false; | ||
| } | ||
| $this->fields = $result->current(); | ||
|
|
||
| return (is_array($this->fields) && count($this->fields)); |
Contributor
There was a problem hiding this comment.
You should be able to simplify it with getFromDBByCrit().
Suggested change
| return $this->getFromDBByCrit(['profiles_id' => $profiles_id]); |
Contributor
Author
There was a problem hiding this comment.
I had also thought about using getFromDBByCrit(), but the problem is that if the query returns multiple results (which is the case here), the function triggers an error.
Rom1-B
approved these changes
Feb 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist before requesting a review
Please delete options that are not relevant.
Description
Problem
The
addRightToAllProfiles()andaddRightToProfile()functions useupdateOrInsert(), which overwrites existing rights each time the plugin is updated.Solution
Both functions now check whether the entry already exists before inserting: