Duplicated relationships on version 1.8.1

Support MB Relationships Duplicated relationships on version 1.8.1Resolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #18328
    luisdelcidluisdelcid
    Participant

    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?

    #18338
    Anh TranAnh Tran
    Keymaster

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.