my $negate = 0;
 
   foreach my $el (@{$ary}) {
+    next unless defined $el;
+
     if (ref $el eq "ARRAY") {
       my $val = evaluate_rights_ary($el);
       $val    = !$val if $negate;
   }
 
   if (!$dont_abort) {
+    $::dispatcher->reply_with_json_error(error => 'access') if $::request->type eq 'json';
+
     delete $::form->{title};
     $::form->show_generic_error($::locale->text("You do not have the permissions to access this function."));
   }