• Resolved Sameer

    (@msameerbutt)


    Dear
    Its very urgent, I just noticed all relation of post among three languages are reset, Its lot of data, can you help me why this can happen and is there any way to recover it.

    Its seems everything is back to zero, either i have to edit each post and link its equivalent post of other language.

    Kindly its urgent matter do reply quickly

    Thanks

    https://www.ads-software.com/plugins/multisite-language-switcher/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Dennis Ploetner

    (@realloc)

    Hi,

    do you changed the language settings?

    Cheers,
    Dennis.

    Thread Starter Sameer

    (@msameerbutt)

    Thanks you very much for quick response.

    No i did not change the language settings
    I do upgraded from wordpress 4.0 to wordpress 4.0.1 and then wordpress 4.1

    But i dont think it create that problem.

    I have three languages (English/French/Arabic)
    I have queryed from database it shows in options table the following

    English has only :33 linking
    Arabic has :251 Linking
    French has :268 Linking

    from that i hope i can recovered english linking if you can guide me
    on this
    Please

    Plugin Author Dennis Ploetner

    (@realloc)

    But how can this be possible? Do you cleaned something in the options-tables? You could try to enter in every French post and save it one by one…

    Cheers,
    Dennis.

    Thread Starter Sameer

    (@msameerbutt)

    Thanks,

    Actually i am thinking to write a short script to sync the linking

    can you please confirm the format:

    for post it will be:

    suppose xx/yy/zz are ids of post in en/ar/fr
    msls_xx = array(‘lang1’=>yy,’lang2’=>’zz’,i=>’xx’);

    for taxonomy_term
    msls_term_xx = array(‘lang1’=>yy,’lang2’=>’zz’,i=>’xx’);

    is above is correct?

    Thread Starter Sameer

    (@msameerbutt)

    Hi Thanks for you help

    I have write a piece of code which will sync the language linking if someone fall into the same problem

    public function adjust_language_linking($source_lang='ar',$target_lang='us',$third_lang='fr_FR',$type="term",$limit=80){
        global $wpdb;
        $blog_ids = array("us" => array('blog_id'=>1,'title'=>'English'), "ar" =>array('blog_id'=>2,'title'=>'Arabic'), "fr_FR"=>array('blog_id'=>3,'title'=>'French'));
        $search_type = array('post'=>'msls_','term'=>'msls_term_');
        $target_blog_id = $blog_ids[$target_lang]["blog_id"];
        $source_blog_id = $blog_ids[$source_lang]["blog_id"];
        switch_to_blog( $source_blog_id );   
    
        $Sql = "
        SELECT * FROM ".$wpdb->prefix."options O
        WHERE 1 AND O.<code>option_name</code> LIKE '".$search_type[$type]."%'
        ORDER BY O.<code>option_id</code> ASC
        LIMIT 0,$limit
        ";    
    
        $posts = $wpdb->get_results($Sql, ARRAY_A );
        $counter = 0;
        $insert_query = array();
        foreach ( (array) $posts as $post ) {
          $counter++;
          $source_id = $post["option_name"];
          $source_id = str_replace($search_type[$type], '', $source_id);
    
          $options_value = unserialize($post["option_value"]);
          $insert = array();
          if(is_numeric($source_id)){
            echo $counter. "## Source [".$blog_ids[$source_lang]["title"]."] ID:".$source_id."  Target [".$blog_ids[$target_lang]["title"]."] ID: ".@$options_value[$target_lang]."  Third [".$blog_ids[$third_lang]["title"]."] ID:".@$options_value[$third_lang]."<br>";
            if(isset($options_value[$target_lang]) && !empty($options_value[$target_lang])){
            $insert["option_name"] = "msls_term_".$options_value[$target_lang];
            $insert["option_value"][$source_lang] = $source_id;
            if(isset($options_value[$third_lang]) && !empty($options_value[$third_lang])){
              $insert["option_value"][$third_lang] = $options_value[$third_lang];
            }
            $insert_query[] = "('".$insert["option_name"]."','".serialize($insert["option_value"])."','no')";
            }
          }
        }
        if(!empty($insert_query)){
          switch_to_blog( $target_blog_id );
          $Main_Query = "INSERT IGNORE INTO ".$wpdb->prefix."options (option_name,option_value,autoload) VALUES ".implode(',', $insert_query);
        }
        echo "<br><br><br>".$Main_Query;
        restore_current_blog();
      }

    May be it can help someone
    Once again thanks.

    Plugin Author Dennis Ploetner

    (@realloc)

    I’m happy that you sorted out the problem. You will find this peace of code useful because it seems that you don’t know what exactly caused the problem: https://github.com/lloc/msls-importer/blob/master/msls-importer.php

    Cheers,
    Dennis.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘All relation seems reset’ is closed to new replies.