if you add a comment without switching workflow state,
and you have locale module enabled,
on the /worklow page of the node you get:
"warning: preg_match() expects parameter 2 to be string, array given in Z:\home\test\www\includes\bootstrap.inc on line 771."

The problem is that workflow tries to wrap previous state name with t();
in workflow.pages.inc (56)

$old_state_name = check_plain(t($states[$history->old_sid]));

obviously, t('') returns array of all translations, and check_plain gets array instead of string.

if you replace the line above with the following code, the error is gone.

if (!empty($history->old_sid)) {
    $old_state_name = check_plain(t($states[$history->old_sid]));
} else {
   $old_state_name = '';
}

Comments

restyler’s picture

May be the problem is deeper though, and it is incorrect that $history->old_sid is empty.

bobsinglar’s picture

Priority: Normal » Critical

I'm facing exactly the same problem.

Do you think it will be fixed on the next module release ?

thank you,
bob

samuelsov’s picture

Title: warning: preg_match() expects parameter 2 to be string, array given in Z:\home\test\www\includes\bootstrap.inc on line 771. » warning: preg_match() expects parameter 2 to be string, array given in bootstrap.inc on line 771.
Priority: Critical » Normal
StatusFileSize
new693 bytes

Here is a slightly different patch that propose restyler.
In that case the old_sid should be the same as the actual sid so what i propose is :

<?php
if (!empty($history->old_sid)) {
  $old_state_name = check_plain(t($states[$history->old_sid]));
} else {
  $old_state_name = check_plain(t($states[$history->sid]));
}
?>

But like restyler said, maybe we should have a value in old_sid instead...

janusman’s picture

Version: 6.x-1.4 » 6.x-1.x-dev
StatusFileSize
new577 bytes

Don't know if this will be attended since it's in 6.x-1.x, but here's a shot anyways =)

old_state can be empty if nodes were created before workflow.module was active and/or a workflow was assigned to that/those nodetype(s).

To me the problem is that t() is being called too many times, once upon populating $states:

function workflow_tab_page($node = NULL) { 
  // [...]
  $result = db_query("SELECT sid, state FROM {workflow_states} WHERE status = 1 ORDER BY sid");
  while ($data = db_fetch_object($result)) {
    $states[$data->sid] = check_plain(t($data->state));
  }

and then below when trying to display it! (note the unnecessary use of check_plain())

      // Regular state.
      $state_name = check_plain(t($states[$history->sid])); // PROBLEM! $states is already localized/sanitized!
    }

    if (isset($deleted_states[$history->old_sid])) {
      $old_state_name = theme('workflow_deleted_state', $deleted_states[$history->old_sid]);
      $footer_needed = TRUE;
    }
    else {
      $old_state_name = check_plain(t($states[$history->old_sid])); // *** HERE TOO !!!! ***
    }

Also the theme_workflow* functions also call t() and check_plain() =)

So, here's a patch for 6.x-1.x.

janusman’s picture

StatusFileSize
new1.56 KB

Oops, wrong patch. Here's an updated one.

johnv’s picture

Title: warning: preg_match() expects parameter 2 to be string, array given in bootstrap.inc on line 771. » warning: preg_match() expects parameter 2 to be string, array given in bootstrap.inc on line 771 (D6)
Issue summary: View changes

I cannot reproduce this in D7, since it assigns a 'creation' state to the node as soon a you try to change it.
D6 version of Workflow is unmaintained, buut I'll keep this open for other users.

johnv’s picture

Status: Needs review » Closed (won't fix)

I wish there was a nicer way to clear the issue queue from 'D6-issues that are fixed in D7' then a "won't fix for D6."