• Resolved gerem

    (@gerem)


    Hello,

    I am using your great plugin.
    But I am facing an issue :
    – I have a template that save serialize data : key1/value1, key2/value2
    – I have checked : “Do Not add empty field in the DB”

    But in database, if my key2/value2 is empty, that data is save with “”.

    I think that your plugin must skip the data ?

    Exemple :
    value1 = value1
    value2 = empty

    Result in database : a:2:{i:0;s:4:”key1″;i:1;s:0:””;}
    Result expected : a:1:{i:0;s:4:”key1″;}

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter gerem

    (@gerem)

    I found a way to to this, but the plugin must be updated.
    I put below the code :
    File to modify Path : /wp-import-export-lite/includes/classes/import/class-wpie-import-engine.php

    Line 510, add some code into the if

    if ( ($not_add_empty === 1 && ((is_scalar( $meta_value ) && trim( ( string ) $meta_value ) !== "") || (!empty( $meta_value ))) ) || $not_add_empty !== 1 ) {
    
    									//We delete empty meta_value to not store in DB empty field
    									$new_meta_value = array();
    									foreach ( $meta_value as $array_key => $array_value ) 
    									{
    										if($array_value != "" && !empty($array_value))
    										{
    											$new_meta_value[$array_key] = $array_value;
    										}
    									}
    
    									$meta_value = $new_meta_value;
    								
                                        $this->update_meta( $meta_key, $meta_value );
                                    }
    • This reply was modified 2 years, 7 months ago by gerem.
    Plugin Author vjinfotech

    (@vjinfotech)

    Hi,

    Thanks for getting in touch

    We will fix issue as soon as possible.

    Let me know if you have any questions

    Thanks and have a nice day

    • This reply was modified 2 years, 7 months ago by vjinfotech.
    Thread Starter gerem

    (@gerem)

    a little fix of my code : test if the meta_value is an array (ie, if it is a serialized data)

    if ( ($not_add_empty === 1 && ((is_scalar( $meta_value ) && trim( ( string ) $meta_value ) !== "") || (!empty( $meta_value ))) ) || $not_add_empty !== 1 ) {
    
    									if(is_array($meta_value)) //If value is an array, so it is serialize data
    									{
    										//We delete empty meta_value to not store in DB empty field
    										$new_meta_value = array();
    										foreach ( $meta_value as $array_key => $array_value ) 
    										{
    											if($array_value != "" && !empty($array_value))
    											{
    												$new_meta_value[$array_key] = $array_value;
    											}
    										}
    
    										$meta_value = $new_meta_value;
    									}
    									
                                        $this->update_meta( $meta_key, $meta_value );
                                    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Import serialize empty data problem’ is closed to new replies.