From 9fbd59d74665ce40de67048abca963c5159d7ac2 Mon Sep 17 00:00:00 2001
From: Earl Miles <merlin@logrus.com>
Date: Thu, 30 Apr 2009 23:41:27 +0000
Subject: [PATCH] Fix invalid context ID creation.

---
 delegator/plugins/tasks/page.inc | 9 ++++++---
 includes/context.inc             | 6 ++++--
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/delegator/plugins/tasks/page.inc b/delegator/plugins/tasks/page.inc
index 9e1ff9d2..d40f030d 100644
--- a/delegator/plugins/tasks/page.inc
+++ b/delegator/plugins/tasks/page.inc
@@ -56,7 +56,11 @@ function delegator_page_delegator_tasks() {
 //      'page callback' => 'delegator_page_execute',
       // context only items
       'handler type' => 'context',
-      'get arguments' => 'delegator_page_get_arguments',
+      'get arguments' => array(
+        'file' => 'page.admin.inc',
+        'path' => drupal_get_path('module', 'delegator') . '/plugins/tasks',
+        'function' => 'delegator_page_get_arguments',
+      ),
       'get context placeholders' => 'delegator_page_get_contexts',
       'access restrictions' => 'delegator_page_access_restrictions',
       'uses handlers' => TRUE,
@@ -333,13 +337,12 @@ function delegator_page_execute($subtask_id) {
  * Return a list of arguments used by this task.
  */
 function delegator_page_get_arguments($task, $subtask_id) {
-  $page = delegator_page_load($subtask_id);
+  $page = delegator_page_get_page_cache($subtask_id);
   return _delegator_page_get_arguments($page);
 }
 
 function _delegator_page_get_arguments($page) {
   $arguments = array();
-
   if (!empty($page->arguments)) {
     foreach ($page->arguments as $keyword => $argument) {
       if (isset($argument['name'])) {
diff --git a/includes/context.inc b/includes/context.inc
index a2b329cb..55d7651d 100644
--- a/includes/context.inc
+++ b/includes/context.inc
@@ -619,9 +619,10 @@ function ctools_context_id($context, $type = 'context') {
  *   The name being used.
  */
 function ctools_context_next_id($objects, $name) {
+  $id = 0;
   // Figure out which instance of this argument we're creating
   if (!$objects) {
-    return $id;
+    return $id + 1;
   }
 
   foreach ($objects as $object) {
@@ -631,7 +632,8 @@ function ctools_context_next_id($objects, $name) {
       }
     }
   }
-  return $id;
+
+  return $id + 1;
 }
 
 
-- 
GitLab