Each time I submit a new node (and not necessarily an issue node), I have the following warning:
warning: implode() [function.implode]: Bad arguments. in sites/all/modules/project_issue/project_issue.views.inc on line 147.

I don't use views (views is not listed as a requirement yet, for project_issue) , so I wonder why the .inc file is called at all.

Comments

beginner’s picture

Correction: views.module was indeed enabled on the site. Looking at the code, the contrary would have been surprising.

I have turned off views since I don't actually need it, so that solves my problem.
The bug probably remains, though.

aclight’s picture

Status: Active » Postponed (maintainer needs more info)

The only way I can see this error message coming about is if you had no statuses defined at /admin/project/project-issue-status or if you modified your db so that none of the statuses were included in the default query.

Are either of these the case on your site?

beginner’s picture

Status: Postponed (maintainer needs more info) » Active

No.
In /admin/project/project-issue-status I have I guess a standard setup: many statuses, several in default queries, one default status, etc.
I don't recall making any change anywhere that would affect this issue.

I reenabled views for a while to check if the other administrator had created another view for testing purposes that could have accounted f or this, but I couldn't find anything but default views.

Maybe it's a worksform problem. I can't say more that could be helpful, but if you're sure this bug shouldn't occur, maybe it's still something on our site that causes it and you can won't fix this issue.

aclight’s picture

Line 148 in project_issue.views.inc is the line in HEAD that is causing problems for you, I believe. I suspect that you have not updated your code since a fairly recent one line commit to the module was made. Here is that line:

'#options' => array('defaults' => implode(',', project_issue_state(0, false, false, 0, true))) + project_issue_state(),

Since your error message says that implode has bad arguments, that must mean that the return value ofproject_issue_state(0, false, false, 0, true) is NULL, because that is the only way I was able to get implode to give me the same error you reported.

Here is the code of project_issue_state():

function project_issue_state($sid = 0, $restrict = false, $is_author = false, $current_sid = 0, $defaults = false, $account = NULL) {
  static $options;

  if (!$options) {
    $result = db_query('SELECT * FROM {project_issue_state} ORDER BY weight');
    while ($state = db_fetch_object($result)) {
      $options[] = $state;
    }
  }

  foreach($options as $state) {
    if ($restrict) {
      // Check if user has access,
      // or if status is default status and therefore available to all,
      // or if user is original issue author and author has access,
      // or if the issue is already in a state, even if the user doesn't have
      //   access to that state themselves.
      if (user_access('set issue status '. str_replace("'", "", $state->name), $account)
          || user_access('administer projects', $account)
          || ($state->sid == variable_get('project_issue_default_state', 1))
          || ($state->author_has && $is_author)
          || ($state->sid == $current_sid) ) {
        $states[$state->sid] = $state->name;
      }
    }
    else if ($defaults) {
      if ($state->default_query) {
        $states[$state->sid] = $state->name;
      }
    }
    else {
      $states[$state->sid] = $state->name;
    }
  }

  return $sid ? $states[$sid] : $states;
}

In this particular invocation of the function, the $defaults parameter is TRUE, so the code that gets executed within the foreach block is this:

    else if ($defaults) {
      if ($state->default_query) {
        $states[$state->sid] = $state->name;
      }
    }

The return value of the function is this:

return $sid ? $states[$sid] : $states;

Because the $sid parameter to the function is 0, $states will always be the return value. The only way I see that $states could be NULL is if you have either no statuses, so nothing within the foreach loop gets executed, or you have no states that are in the default query, in which case $states won't be populated, and since it's not initialized earlier in the function it will be NULL.

Am I missing something obvious here? Can you make sure that the line you're getting the error on is the same line I pasted at the top of this comment? Also, maybe you can debug a bit in project_issue_state() and see if you can figure out what is going on.

Ideally, we would initialize $state to be array() at the top of the function, and for the D6 version we will have to to prevent notices, but I don't see how this would actually matter if your states are as you tell me they are.

beginner’s picture

yes, the line is the same (sorry, I should have pasted it earlier).

'#options' => array('defaults' => implode(',', project_issue_state(0, false, false, 0, true))) + project_issue_state(),

I had updated the site to the latest 5--2 version from cvs update 2 or 3 weeks ago.

Sorry: I don't have time to investigate more right now. My business premises where I write from got flooded twice in two days. I just got back online for a short while yesterday, and again a few minutes ago. I am among the lucky ones, but I have a few things to attend to as a result of the flooding.