Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

User connection not synchronizing #4

Closed
akbortoli opened this Issue · 0 comments

2 participants

@akbortoli

Here is a patch.

--- YHiA39_synchronizer.php 2012-07-04 22:22:49.000000000 +1200
+++ synchronizer.php 2012-07-04 22:21:51.000000000 +1200
@@ -120,8 +120,13 @@
                foreach($fromConnections as $fromConnection) {
                    $toPostId = $fromConnection->p2p_to;

+                   // check for 'user' type connection
+                   $isUserConnecton = false;
+                   if ( preg_match( '#_?user_?#is', $fromConnection->p2p_type ) )
+                       $isUserConnecton = true;
+
                    //check if the destination post is translated
-                   if(self::is_post_translated($toPostId)) {
+                   if(!$isUserConnecton && self::is_post_translated($toPostId)) {
                        $toTranslationIds = self::get_post_translation_ids($toPostId);
                        if(isset($toTranslationIds[$lang])) $connections[] = array(
                            'from' => $postId,
@@ -148,8 +153,13 @@
                foreach($toConnections as $toConnection) {
                    $fromPostId = $toConnection->p2p_from;

+                   // check for 'user' type connection
+                   $isUserConnecton = false;
+                   if ( preg_match( '#_?user_?#is', $toConnection->p2p_type ) )
+                       $isUserConnecton = true;
+
                    //check if the origin post is translated
-                   if(self::is_post_translated($fromPostId)) {
+                   if(!$isUserConnecton && self::is_post_translated($fromPostId)) {
                        $fromTranslationIds = self::get_post_translation_ids($fromPostId);
                        if(isset($fromTranslationIds[$lang])) $connections[] = array(
                            'from' => $fromTranslationIds[$lang],
@@ -174,11 +184,16 @@
        $isFromTranslated = self::is_post_translated($fromId);
        $isToTranslated = self::is_post_translated($toId);

+       // check for 'user' type connection
+       $isUserConnecton = false;
+       if ( preg_match( '#_?user_?#is', $type ) )
+           $isUserConnecton = true;
+
        $connections = array();

        if($isFromTranslated) {
            $fromTranslationIds = self::get_post_translation_ids($fromId);
-           if($isToTranslated) {
+           if(!$isUserConnecton && $isToTranslated) {
                $toTranslationIds = self::get_post_translation_ids($toId);
                foreach($fromTranslationIds as $lang => $fromTranslationId) {
                    if(isset($toTranslationIds[$lang])) {
@@ -213,7 +228,7 @@

    private static function p2p_delete($idsStr) {
        $connectionIds = explode(',', $idsStr);
-       
+
        foreach($connectionIds as $connectionId) {
            $connection = self::get_connection_data($connectionId);
            if(empty($connection)) continue;
@@ -227,11 +242,16 @@
                'from' => $connection['from'],
                'to' => $connection['to']   
            );
+
+           // check for 'user' type connection
+           $isUserConnecton = false;
+           if ( preg_match( '#_?user_?#is', $connection['type'] ) )
+               $isUserConnecton = true;

            if($isFromTranslated) {
                $fromTranslationIds = self::get_post_translation_ids($connection['from']);

-               if($isToTranslated) {
+               if(!$isUserConnecton && $isToTranslated) {
                    $toTranslationIds = self::get_post_translation_ids($connection['to']);

                    foreach($fromTranslationIds as $lang => $fromTranslationId) {
@cubica cubica closed this issue from a commit
@cubica added metadata synchronization
refactoring
bug fixing
closes #4, #5, #6
f4b38c2
@cubica cubica closed this in f4b38c2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.