form ); // Hide booking details and for having (not changed Cache object from DB $wpbc_global_cache['wpbc__sql__get_booking_dates'][ $params_cache ] ) During loading bookings in wpbc_get__booked_dates__per_resources__arr(...) we need to clone each such object, otherwise if we change something in this variable, it will be changed in cache $wpbc_global_cache['wpbc__sql__get_booking_dates'][ $params_cache ] ), as well Otherwise, if we will not clone and use this, then we do not need to unset some properties: $this_date_bookings = $booked_dates__per_resources__arr[ $my_day_tag ][ $resource_id ]; v.s. $this_date_bookings = array_map( function ( $object ) { return clone $object; } , $booked_dates__per_resources__arr[ $my_day_tag ][ $resource_id ] ); */ function wpbc_clone_array_of_objects( $object_arr ){ $cloned_result = false; if ( is_array( $object_arr ) ) { $cloned_result = array_map( function ( $object ) { return ( ( is_object( $object ) ) ? ( clone $object ) : $object ); } , $object_arr ); } else if ( is_object( $object_arr ) ) { $cloned_result = ( clone $object_arr ); } else { $cloned_result = $object_arr; } return $cloned_result; }