Event::canView() and canEdit() may ask the user for the permission
($u->canView('Events')) instead of reading the field, which counts a
role as well. The test's stub user only had the field getters, so such
an Event.php ends in a fatal error. The stub answers as User::canView()
and canEdit() do for a user without a role; the field getters stay for
the current Event.php.
(cherry picked from commit ea741802dd)
ZM\Event::canView() and canEdit() asked the event's Monitor, and an
Event with no MonitorId (built from an empty or failed lookup) gets an
empty Monitor, whose canView() falls back to the user's global Monitors
permission. So an Event with no Id passed both checks for any user with
Events access, whatever monitors they were denied. A caller that built
an Event from a lookup that could come back empty and trusted canView()
without checking Id() first failed open; the API's events/view did.
Return false from both when the Event has no Id. Every caller in the
web UI, ajax and API either checks Id() first or builds the Event from
a database row, so none relied on the empty Event passing; callers that
did not check (the frame view, export and download lists) now refuse a
missing event id instead of working on an empty one.
Test: tests/php/test_event_can_view_no_id.php drives the real ZM\Event
with a stub Monitor (8 of 13 checks fail before this change).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 054d4f0fa6)