Skip to content

Remove unnecessary permission check in segment star/unstar (#24094)#24896

Open
caddydove wants to merge 1 commit into
matomo-org:5.x-devfrom
caddydove:fix/segment-star-permission
Open

Remove unnecessary permission check in segment star/unstar (#24094)#24896
caddydove wants to merge 1 commit into
matomo-org:5.x-devfrom
caddydove:fix/segment-star-permission

Conversation

@caddydove

Copy link
Copy Markdown

Description

Fixes #24094 — starring or unstarring a segment should not require edit/delete permissions.

Root cause

The star() and unstar() methods in plugins/SegmentEditor/API.php call checkUserCanEditOrDeleteSegment() 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:

  • The user has view access
  • The segment exists and is not deleted
  • The user has access to the segment's site

Fix

Remove the checkUserCanEditOrDeleteSegment() call from both star() and unstar(). This allows any user who can see a segment to star or unstar it.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] When starring a segment, an unnecessary error shows up

1 participant