The current_user() method returns null if the user is anonymous. With the previous implementation, one would see frequent warnings such as this in PHP logs.
PHP Warning: Attempt to read property "role" on null
This update adds checks to ensure that the current user is not null before attempting to access its properties.
I didn't update the instances of this method's use in views/admin/mirador/annotator.php because I figured it should be impossible to reach that code if you are not logged in.
Thank you for the PR. Going forward, instead of fetching roles from current_user(), I would prefer to migrate the permissions to an ACL-based setup. Example from a recent retrofit on Job Diagnostics:
The
current_user()
method returns null if the user is anonymous. With the previous implementation, one would see frequent warnings such as this in PHP logs.PHP Warning: Attempt to read property "role" on null
This update adds checks to ensure that the current user is not null before attempting to access its properties.
I didn't update the instances of this method's use in
views/admin/mirador/annotator.php
because I figured it should be impossible to reach that code if you are not logged in.My editor also removed all trailing whitespace.