2 invalid argument errors that i can't resolve due to bad php knowledge

cryztov - March 23, 2007 - 09:11
Project:Workflow Fields
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:kratib
Status:closed
Description

* warning: Invalid argument supplied for foreach() in C:\Program Files\xampp\xampp\htdocs\Drupcrm\sites\default\modules\workflow_fields\workflow_fields.module on line 59.
* warning: Invalid argument supplied for foreach() in C:\Program Files\xampp\xampp\htdocs\Drupcrm\sites\default\modules\workflow_fields\workflow_fields.module on line 85.

#1

colesidhu - March 24, 2007 - 08:25

I get the same errors.

I first created a workflow.

If I try to add new states without first selecting the node type involved, I get the error messages listed above.

However, if I first select the node type involved and click "Save Workflow Mapping", THEN try to add a new state, I dont get any error messages.

I should note as well that it looks like only 1 node type can be referenced in this way; if I try to add more than 1 node type for a workflow, only the fields for the first one appear.

Actually, even if I do all this and with all different combinations, I still cant get the workflow fields to work.

#2

hbfkf - April 11, 2007 - 08:49

I get the same error.

#3

hbfkf - April 11, 2007 - 09:04
Status:active» patch (code needs review)

As noted by colesidhu, the bug does not manifest if you first save a workflow mapping in which at least one workflow is assigned to some content type.

I do not have the complete overview of the module's code, but it looks as if the case of no assigned workflow is not handled correctly. Here's a fix (at least for the original poster's problem, maybe not for the problem colesidhu mentions) that works for me.

Index: workflow_fields.module
===================================================================
--- workflow_fields.module      (revision 71)
+++ workflow_fields.module      (working copy)
@@ -50,6 +50,8 @@
   if (is_null($type)) return;
   if (module_exists('content') && ($content = content_types($type))) {
     $fields = $content['fields'];
+    if (is_null($fields))
+      return;
     $form['submit_chain'] = array('#type' => 'value', '#value' => $form['#submit']);
     $form['#submit'] = array('workflow_fields_state_form_submit' => array());
     $form['fields'] = array();
@@ -80,6 +82,8 @@
   $type = $form['type']['#value'];
   $content = content_types($type);
   $fields = $content['fields'];
+  if (is_null($fields))
+    return;
   $header = array(t('Field name'), t('Visible'), t('Editable'));
   $rows = array();
   foreach($fields as $field) {

I attach this diff also as a text-file.

Could others please check whether this solves the issue?

AttachmentSize
patch_workflow_fields.txt865 bytes

#4

hbfkf - April 11, 2007 - 09:10

Colesidhu, could you maybe post your second issue as a separate problem report (if none already exists)? This would allow this bug to be closed as soon as we have a good fix! Thanks!

#5

syoumans - June 29, 2007 - 13:04

This fix patch worked for me; I applied it to version 5.x-1.x-dev.

#6

kratib - July 18, 2007 - 21:13
Assigned to:Anonymous» kratib
Status:patch (code needs review)» fixed

Line 50: I changed

if (is_null($type)) return;

to
if (!$type) return;

Please verify and close if everything OK.

#7

Anonymous - August 1, 2007 - 22:08
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.