Project does not seem to be loading components. I get a:

warning: Invalid argument supplied for foreach() in /home/eaberry/public_html/sites/cvs/drupal/modules/project/issue.inc on line 365.

error when I run the latest cvs version of project and i try and submit an issue to a project.

Setup:
Apache 2.0
PHP 5
MySQL 4.3
Drupal: 4.7 (cvs)
Taxonomy: On

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Souvent22’s picture

Upon investigation, it seems that after validation, even though it's passing by reference, it does not hold the component value after it's transfomed. Don't know if this is a larger Drupal issue? or project.

pfaocle’s picture

Version: » x.y.z

Confirmed here, too. It could be that the components aren't saving properly when a project is edited, as my existing projects' components load fine... but once edited, they are lost. The submit issue form after editing a project does not display any components, usually resulting in not being able to submit a new issue, as component is a required field.

Changing to correct version.

Haven't looked into this one any further yet...

pfaocle’s picture

Title: No Components are Loading » Components field doesn't save to database correctly
Status: Active » Needs work
FileSize
1.58 KB

Seems the _update hook isn't saving the components correctly. Attached patch seems to fix, but needs review and proper testing.

pfaocle’s picture

Status: Needs work » Active

Nope - doesn't quite fix. Fields seem to be saved correctly, but aren't being represented in the option tag properly:

<option value="Content
">Content
</option><option value="User interface
">User interface
</option><option value="Hosting
">Hosting
</option><option value="Documentation
">Documentation
</option><option value="Financial
">Financial
</option><option value="Miscellaneous">Miscellaneous</option></select>
</div>

The line break breaks being able to submit to any of the above components bar 'Miscellaneous'.

pfaocle’s picture

Status: Active » Needs review
FileSize
1.58 KB

Another shot. It seems to work here, but I'm curious as to why ...update needs this and ..._insert doesn't.

pfaocle’s picture

Still an issue with latest HEAD - can anyone confirm?

wilh’s picture

Version: x.y.z » 4.6.x-1.x-dev

This is still an issue with 4.6.0 release. Is there a patch for 4.6.0 or do I need to start over from CVS and patch from there?

pfaocle’s picture

Title: Components field doesn't save to database correctly » Components field doesn't save to database correctly http://drupal.org/project/comments/add/38120
Version: 4.6.x-1.x-dev » x.y.z

A new patch, adapted from this one from 'must'.

pfaocle’s picture

Title: Components field doesn't save to database correctly http://drupal.org/project/comments/add/38120 » Components field doesn't save to database correctly

Ooops.

Souvent22’s picture

FileSize
1.67 KB

Patch to fix compontns not saving AND fixes compontnes not carrying over and saving when you create an issue. I used to get 'You must specify a valid component' every time. This fixes that.

Souvent22’s picture

Assigned: Unassigned » Souvent22

Note: There is an issue with the projects taxonomy/category not being selected when you go back in and edit a project. However, I believe this is a taxonomy related issue, as the field is added via form_alter from the taxonomy module.

Souvent22’s picture

FileSize
2.37 KB

Re-rolled, was missing 1 diff. Complete patch.

m3avrck’s picture

Fixes creation of new issues, but doesn't fix follow ups for current issues.

Souvent22’s picture

FileSize
3.38 KB

Found same issue in another part of the code.
New patch.

m3avrck’s picture

Status: Needs review » Reviewed & tested by the community

Patch works great, fixes all known issues when creating issues with project module, RTC!

nedjo’s picture

Thanks for the patch, this issue definitely needs fixing.

I'm wondering if this complex handling is needed. How do we handle the question of converting multi-line lists into arrays in other cases? I'm thinking that we do this in the profile.module. Here are some potentially relevant lines:


        $values = split("[,\n\r]", $value);
        $fields = array();
        foreach ($values as $value) {
          if ($value = trim($value)) {
            $fields[] = $browse ? l($value, "profile/". drupal_urlencode($field->name) ."/". drupal_urlencode($value)) : check_plain($value);
          }
        }
        return implode(', ', $fields);

Can we do the same here?

dan_aka_jack’s picture

Hi there,

Just wondering... is patch3 still required or has this patch been integrated into the CVS version of the projects module? I assume it is still required.

Many thanks,
Jack

dan_aka_jack’s picture

OK, I just tried applying patch 3 against version 1.140 of issues.inc and I've also tried updating to the very latests CVS code but I'm afraid neither fixed the problem described here:

http://drupal.org/node/44572

Thanks,
Jack

tfejos’s picture

I had the same problem. It seems to be resolved by issue_3.patch .
I need more tests to be sure about it.
(if I wont write more bug reports for project, then it is OK)
Project on 4.7 seems to be compatibile with 4.7.

dan_aka_jack’s picture

Is there any news about whether or not this patch will be entered into the CVS repository for the Project module?

Thanks,
Jack

Souvent22’s picture

I'll re-roll this patch from head. Hopefully it goes it soon.

markus_petrux’s picture

Is it possible that this issue has already been fixed? Patch3 is for 1.140, but issue.inc is now 1.142 (2006/01/16).

/me asking 'cause I just have tested this module...

- created a project.
- created an issue, selecting one of the existing components.
- viewed issue, looks good.
- edited project, adding a new component to the list.
- edited issue changing the component, selecting the one that I just created.
- viewed issue, looks good.

It all worked for me.

nedjo’s picture

Status: Reviewed & tested by the community » Fixed

The problem was that validation wasn't being called just before the node was saved (presumably this is a change in the order of calls) so the components string wasn't being converted into an array (as this happened in project_project_validate()). I've changed this to do call the conversion in project_project_insert() and project_project_update(), which appears to fix the issue. Fix applied.

dan_aka_jack’s picture

Hi there,

I've just tried installing the most recent code from the CVS but I'm afraid I still can't add a feature request / bug report to a project because I can't select any projects.

I have the taxonomy module installed (I need it). Does the taxonomy module still break the project module (I would try disabling the taxonomy module but I'm afraid I can't because it gets used so much).

Many thanks,
Jack

nedjo’s picture

Can't reproduce this error, and it doesn't appear to be necessarily related to this issue.

Make sure you're creating a new project to submit issues on, as your existing data may have errors. If you still have problems, submit a separate detailed support request.

Anonymous’s picture

Status: Fixed » Closed (fixed)