From ffae2d2318ee252cad49a527ae0e349a3c3cf909 Mon Sep 17 00:00:00 2001
From: Axel Rutz <axel.rutz@clever-systems.net>
Date: Mon, 29 Dec 2014 01:52:58 +0100
Subject: [PATCH] Issue #2399313: Relationship handling broken with optional
 required context

---
 includes/context.inc | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
 mode change 100644 => 100755 includes/context.inc

diff --git a/includes/context.inc b/includes/context.inc
old mode 100644
new mode 100755
index 3b75c0f..b00e85f
--- a/includes/context.inc
+++ b/includes/context.inc
@@ -994,17 +994,15 @@ function ctools_context_get_context_from_relationships($relationships, &$context
     if (is_array($rdata['context'])) {
       $rcontexts = array();
       foreach ($rdata['context'] as $cid) {
-        if (empty($contexts[$cid])) {
-          continue 2;
+        if (!empty($contexts[$cid])) {
+          $rcontexts[] = $contexts[$cid];
         }
-        $rcontexts[] = $contexts[$cid];
       }
     }
     else {
-      if (empty($contexts[$rdata['context']])) {
-        continue;
+      if (!empty($contexts[$rdata['context']])) {
+        $rcontexts = $contexts[$rdata['context']];
       }
-      $rcontexts = $contexts[$rdata['context']];
     }
 
     $cid = ctools_context_id($rdata, 'relationship');
-- 
2.1.0

