[wp-trac] [WordPress Trac] #58016: Plugin try to access an empty array at makewebbetter-hubspot-for-woocommerce/includes/class-hubwoodatasync.php 438

WordPress Trac noreply at wordpress.org
Thu Mar 30 03:58:49 UTC 2023


#58016: Plugin try to access an empty array at makewebbetter-hubspot-for-
woocommerce/includes/class-hubwoodatasync.php 438
--------------------------+-----------------------------
 Reporter:  anhduc.bkhn   |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  6.1.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 My env:
 - WP: 6.1
 - MWB HubSpot for WooCommerce: 1.4.5



 Plugin try to access the role of an user, but in some case, role is an
 empty array.
 How to fix:




 {{{#!php
 <?php
 // File makewebbetter-hubspot-for-woocommerce/includes/class-
 hubwoodatasync.php line 348
 $user_data = get_user_by( 'email', $email );
 $role      = $user_data->roles[0];
 }}}


 We should check if role is empty or not before access

 {{{#!php
 <?php
 $user_data = get_user_by( 'email', $email );

 if (empty($user_data->roles)) {
     continue;
 }

 $role      = $user_data->roles[0];
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58016>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list