Support Forum » User Profile

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Faulty 'capability_type' argument #26744

    Awesome! Thank you, Long!

    in reply to: Faulty 'text_list' update #23116

    I found the problem!

    Since the 'text_list' field has the parameter 'multiple' set to true automatically by MetaBox, in the file /meta-box/inc/field.php, in the function 'save', the "Save cloned fields as multiple values instead serialized array" block is being called (lines 314-321).

    Inside that function, there is a call to $storage->delete( $post_id, $name ).

    Now, moving back to the MetaBox Custom Table plugin, in the function /inc/class-rwmb-table-storage.php there is the function "delete" around line 100. Inside, there is an "if" check for "$delete_all || ! $meta_value || $row[ $meta_key ] === $meta_value" and in there there is an assignment: $row[ $meta_key ] = "";

    Because of that assignment to "", the function "add" a few lines above fails. Namely, when it calls $this->get( $object_id, $meta_key ) because there is an array conversion happening. The exact line is (array) $this->get( $object_id, $meta_key );

    In this case, the "" value gets converted to [""] which is NOT an empty array. All the other values from the text_list get appended and thus the first value is always wrong.

    The solution is one of two:

    a) in the "delete" function, instead of assigning "", assign an empty array [] if the field accepts multiple entries

    b) in the "add" function, rewrite the line $values = (array) $this->get( $object_id, $meta_key ) to:

    
    $values = $this->get( $object_id, $meta_key );
    if ( $values === '' ) {
        $values = array();
    } else {
        $values = (array) $values;
    }
    
Viewing 2 posts - 1 through 2 (of 2 total)