Custom Fields
Re-Envisioned
Support MB Relationships "handle_multiple_relationships" throws an error when no objects were found

  • Creator
    Topic
  • #29858
    Resolved Lee Heewon
    Participant

    When searching for multiple relationships with WP_Query, no error occurs if at least one search result exists.

    However, if the search result does not exist, the following error occurs:

    
    Warning: array_unique() expects parameter 1 to be array, null given in /var/www/html/wp-content/plugins/meta-box-aio/vendor/meta-box/mb-relationships/inc/query/query.php on line 193
    
    Warning: implode(): Invalid arguments passed in /var/www/html/wp-content/plugins/meta-box-aio/vendor/meta-box/mb-relationships/inc/query/query.php on line 194
    

    Temporarily, I'm preventing the error by adding the following code to the end of the function:

    if (empty($merge_object_ids)) {
        $merge_object_ids = '-1';
    } else {
        $merge_object_ids = array_unique( $merge_object_ids );
        $merge_object_ids = implode( ',', $merge_object_ids );
    }
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #29869
    Long Nguyen
    Moderator

    Hi Lee,

    Thank you for your feedback.

    I will inform the development team to fix this issue in the next update.

    #29946
    Lee Heewon
    Participant

    I updated to Meta Box AIO 1.14.3, but there is a problem.

    If there is no object exists corresponds to the relationship condition, it will not change $clause['where'], which will ignore the relationship condition.

    But the correct behavior when the objects are empty is not simply ignoring the relationships.
    So, as I have temporarily modified, please correct the results of the relationships in $cluses['where'].

    #30100
    Lee Heewon
    Participant

    Has the my new issue been informed to the development team?
    I don't want to fix the code every time I update Meta Box AIO later.

    #30102
    Long Nguyen
    Moderator

    Hi Lee,

    Thank you for your feedback.

    This issue has been fixed on this commit. Can you please check it?

    #30111
    Lee Heewon
    Participant

    I didn't know I could check this plugin on Github.
    I think it will be solved enough if the pull request you mentioned is merged.
    Thank you.

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