Custom Fields
Support MB Relationships Duplicated relationships on version 1.8.1

  • Creator
  • #18328
    Resolved luisdelcid

    I'm not able to track since wich version the 'update' method of the 'MBR_Storage' class isn't validating the $meta_value array for containing only unique values but I can explain it this way:

    In version 1.7.0, there was a 'RWMBR_Table_Storage' class instead of the current 'MBR_Storage' class and the 'update' method had the following code:

    $values = array();
      foreach ( $meta_value as $id ) {
      $value = isset( $order[ $id ] ) ? $order[ $id ] : 0;
      $values[ $id ] = $value; // this replaces duplicate values

    So, when you add a duplicated relationship, it would be overwritten on save, but now, in version 1.8.1, the $meta_value array doesn't remove duplicated values, so you can have unlimited identical relationships causing an strange behavior on WP Queries, specially on User Queries

    I think the easiest solution is adding something like:

    $meta_value = array_unique( $meta_value );

    Inside the 'update' method, does it make sense?

Viewing 1 replies (of 1 total)
  • Author
  • #18338
    Anh Tran

    Hi, thanks for your feedback. I've just fixed it and released a new version.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.