Hello!
First thank you for this component.
Fatal error "Call to a member function authorise() on null" in Lends view for non-Super UsersEnvironmentlexandria Book Library (com_abook) 4.0.18
DescriptionIn the administrator, opening the Lends manager (view=lends) with a user who is not a Super User, but whose group has access to the component's administration, causes a fatal error:
0 Call to a member function authorise() on null
administrator/components/com_abook/views/lends/view.html.php:74
AbookViewLends->addToolbar()The page works correctly for Super Users.
CauseIn AbookViewLends::addToolbar(), the variable $user is used but never defined:
php
if ($canDo->get('core.admin') || $user->authorise('core.options', 'com_abook')){For a Super User, core.admin is true, so the second condition is never evaluated. For any other user, $user->authorise() is called on null, which triggers the error.
FixAdd the Factory import and define $user at the start of addToolbar():
diff
use Joomla\CMS\Helper\ContentHelper;
+use Joomla\CMS\Factory;diff
protected function addToolbar()
{
$canDo = ContentHelper::getActions('com_abook');
$toolbar = Toolbar::getInstance();
+ $user = Factory::getApplication()->getIdentity();Tested: the Lends manager now displays correctly for non-Super Users, with toolbar buttons shown according to their permissions.
It may be worth checking other views/*/view.html.php files for the same pattern.
Regards
Thanks a lot for the quick fix! I installed 4.0.19 and the Lends view now works fine for non-Super Users. :)