Skip to content

Fix permissions table user search querying the pivot table - #46

Merged
swilla merged 2 commits into
mainfrom
cursor/fix-permissions-user-search-ca8a
Nov 19, 2026
Merged

swilla merged 2 commits into
mainfrom
cursor/fix-permissions-user-search-ca8a

Conversation

@swilla

@swilla swilla commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Details

Searching a library folder's Permissions tab (for example /library/330/edit-folder) failed on every keystroke. Laravel Nightwatch #11 on Communities of Excellence (portal.connectwithcore.org) recorded MySQL error 1054: Unknown column 'first_name' in 'where clause' against library_item_permissions.

The count query was filtering the permissions table itself:

select count(*) as aggregate
from library_item_permissions
where library_item_id = 330
  and (
    (first_name like '%rachel%' or last_name like '%rachel%' or email like '%rachel%')
    or exists (
      select * from users
      where library_item_permissions.user_id = users.id
        and email like '%rachel%'
    )
  )

LibraryItemPermissionsRelationManager gives the User column a custom searchable(query:) closure. That closure checked Schema::hasColumn('users', 'first_name') (those columns do exist on users) and then applied the LIKE predicates to the query it was given, which is the permissions relation. The neighbouring user.email column already searched through the user relation, which is the exists half of the SQL above. The whole statement still failed because MySQL rejected first_name on the permissions table before that relation search could run.

Fix

The User column search now uses whereHas('user'), so first name, last name, single name, and email are constrained on the related user. The existing column-existence guards are unchanged:

  • when users has both first_name and last_name, search those columns plus email
  • otherwise, when users has name, search name plus email
  • email is always included

Test

tests/Feature/LibraryItemPermissionsRelationManagerSearchTest.php mounts the permissions relation manager and searches the table:

  • by first name, last name, and email when those name columns exist
  • by name and email when users has no first_name or last_name columns

A permission on another folder is not returned. The full Pest suite passes (39 tests).

CI

The "Fix PHP Code Styling" job was failing before it could report a result. aglipanci/laravel-pint-action runs inside composer:latest, which is now PHP 8.5 without mbstring, and Pint's Termwind summary calls mb_strimwidth(). The workflow now installs Pint on PHP 8.3 with mbstring.

This pull request does not tag a release. Versions are git tags (v1.4.2 is current). Publishing GitHub release v1.4.3 is the patch bump Communities of Excellence can install with composer update tapp/filament-library under its existing ^1.4.1 constraint. The changelog workflow updates CHANGELOG.md when that release is published.

Posted by Night Shift, Grok Bot for Steve Williamson

Open in Web Open in Cursor 

cursoragent and others added 2 commits November 19, 2026 18:25
The Permissions tab applied first_name, last_name, and email filters to
library_item_permissions. Scope that search with whereHas('user') so a
folder permissions search matches the user and no longer errors.

Co-authored-by: Steve Williamson <swilla@users.noreply.github.com>
The Pint Docker action uses composer:latest, which is now PHP 8.5 without
mbstring, so the job dies in Termwind after the files have already passed.

Co-authored-by: Steve Williamson <swilla@users.noreply.github.com>
@swilla
swilla marked this pull request as ready for review November 19, 2026 18:32
@swilla
swilla merged commit 78c6a8d into main Nov 19, 2026
2 checks passed
@swilla
swilla deleted the cursor/fix-permissions-user-search-ca8a branch November 19, 2026 18:32
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.

2 participants