gosa-project / gosa-plugins-schoolmanager

GOsa Add-On for Managing Schools
GNU General Public License v2.0
3 stars 5 forks source link

mail aliases not added to user objects anymore (with error) #52

Closed sunweaver closed 2 years ago

sunweaver commented 2 years ago

Today a customer reported these errors:

May  7 09:13:23 tjener php: GOsa[gabmik]: (view) error : PHP error: count(): Parameter must be an array or an object that implements Countable (/usr/share/gosa/plugins/personal/mailaddress/class_mailAccount.inc, line 277) 
May  7 09:13:23 tjener php: GOsa[gabmik]: (view) error : PHP error: Invalid argument supplied for foreach() (/usr/share/gosa/plugins/personal/mailaddress/class_mailAccount.inc, line 279) 

They were caused by a tiny line of code sneaked in via 9dbea004.

This reverts that line. Please note that maybe not all attributes must be strings, some may be arrays. Maybe all should be arrays (as it was before).

The thing is that _user_properties_extras only contains 1 key in my test case ('alias'). So, maybe for some attributes/keys the array to string conversion might be correct while it certainly is not for the alias attribute (there can be more than one aliases per user object).

@dzatoah Please check!

@@ -2099,12 +2101,13 @@

         /* Populate sub-object attributes for $usertab with same values */
         foreach ($_user_properties_extras as $attr => $val) {
-            if (is_array($val)) $val = $val[0];
+//            if (is_array($val)) $val = $val[0];

             $usertab->$attr = $val;
             foreach ($usertab->by_object as $pname => $plugin) {
                 if (isset($usertab->by_object[$pname]->$attr)) {
                     $usertab->by_object[$pname]->$attr = $val;
+                    print $attr.": ".$val."<br>";
                 }
             }
         }