Remove unnecessary permission check in segment star/unstar (#24094)#24896
Open
caddydove wants to merge 1 commit into
Open
Remove unnecessary permission check in segment star/unstar (#24094)#24896caddydove wants to merge 1 commit into
caddydove wants to merge 1 commit into
Conversation
Starring or unstarring a segment is not an edit or delete operation. It only toggles a personal preference flag. The getSegmentOrFail() method already validates the segment exists, the user has view access, the segment site is accessible, and the segment is not deleted. The additional checkUserCanEditOrDeleteSegment() call prevented users from starring segments created by other users, showing an error even though starring is a harmless metadata toggle. Fixes matomo-org#24094
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.
Description
Fixes #24094 — starring or unstarring a segment should not require edit/delete permissions.
Root cause
The
star()andunstar()methods inplugins/SegmentEditor/API.phpcallcheckUserCanEditOrDeleteSegment()which throws an exception if the current user is not the segment creator. This check is unnecessary because starring is a personal metadata toggle — it does not modify the segment's definition, owner, or visibility.The
getSegmentOrFail()call that precedes it already validates that:Fix
Remove the
checkUserCanEditOrDeleteSegment()call from bothstar()andunstar(). This allows any user who can see a segment to star or unstar it.