Fix PHP warning: Trying to access array offset on value of type null
authorChristian Weiske <[email protected]>
Fri, 21 Apr 2023 20:25:29 +0000 (22:25 +0200)
committerChristian Weiske <[email protected]>
Fri, 21 Apr 2023 20:25:29 +0000 (22:25 +0200)
> PHP Warning:  Trying to access array offset on value of type null
> in plugins/nextcloud_sql_addressbook/nextcloud_sql_addressbook.php
> on line 97

nextcloud_sql_addressbook.php

index 146aebee2e79c40b8ee465a93a2aae0863ca9359..5c52fded69b0d07bd366847e89e2fa0f8ebeced6 100644 (file)
@@ -93,6 +93,10 @@ class nextcloud_sql_addressbook extends rcube_plugin
      */
     protected function listAddressbooks()
     {
+        if (!isset($this->rcube->user->data)) {
+            return [];
+        }
+
         $principalUri = 'principals/users/'
             . $this->rcube->user->data['username'];