workflow_field_choices($node) returns an array (if there are any choices) or FALSE otherwise.
This is not very consistent, and makes the code to process this result longer and harder to read. Beste practice is to return an empty array if there are no results. (After all, it is not an error.)
E.g., in the code count() is used: count(FALSE) == 1, and count(array()) == 0.
Also, the result is parsed in several ways, which is confusing to me.
3 files are using this function. Two of them need modification.
If you are interested, I can provide a patch.
Comments
Comment #1
johnvFile workflow_actions.module seems ok:
I haven't figured workflow.pages.inc out: line 128 seems wrong to me.
File workflow.module needs some more love:
Comment #2
nancydruLine 128 (your number, 184 in my code) is to prevent a workflow change form if there are no states to switch to. That line has been there forever, even in the 6.x branch.
I have made the third change.
Comment #2.0
nancydruadd text.
Comment #3
johnvAttached patch makes the code a bit clearer, by using a more familiar code construct.
(The thing in line 128 happens on more occasions, but also in several different wordings. )
(Sorry for the nit-picking, but I try to understand the code for my FieldAPI issue.)
Comment #4
nancydruChange committed. Nit picking is fine. Since I got involved with this module late in the game, it is not yet to my personal specs.
Comment #5
johnvSources seem OK , now.
Comment #6
johnvMarked as duplicates:
#2048327: array_key_exists() expects parameter 2 to be array, boolean given
#865196: Workflow state errors when saving node: array_key_exists() in workflow_transition()
Comment #7.0
(not verified) commentedremove typo's.