When creating a new state, the state name is not checked against existing state names. So it's no problem to create several states with the same state name.

I'm not sure there whether this could be useful in some special cases, but the user should at least be warned and asked to confirm.

CommentFileSizeAuthor
#2 workflow_and_state_validation.patch13.79 KBPancho
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Pancho’s picture

Title: Duplicate state names possible » Duplicate workflow / state names possible

Same with workflow names... at least a confirmation message would be helpful to avoid confusion.

Pancho’s picture

Status: Active » Needs review
FileSize
13.79 KB

Okay now, this is the last patch for today...

it's a bit bigger than the others. What I'm doing here is:

  • workflow_add_form_validate()
    • CHECK FOR DUPLICATE WORKFLOW NAME
  • workflow_add_form_submit()
    • set a watchdog message
    • get rid of the "theme('placeholder')" cruft (this is automatically handled by Drupal 5)
    • theme message as warning ("You should add states to your workflow")
  • workflow_delete_form_submit()
    • set a watchdog message (consistently moved from workflow_deletewf())
    • get rid of the "theme('placeholder')" cruft
  • theme_workflow_edit_form()
    • set a meaningful title
    • set a warning if author may not perform any transition (moved from validate: it's best to set the message then, when the user has a chance to fix the problem, and not afterwards. Also rewritten: shorter. It is always triggered, even when there is no transition at all - a warning is no error, so this doesn't hurt.)
  • workflow_edit_form_validate()
    • use existing function instead of own query
    • moved warning to form
    • reworded error messages consistently
    • erroneous field now marked with red border
  • workflow_edit_form_submit()
    • reworded message consistently
    • consistently use "drupal_goto"
  • workflow_state_add_form()
    • use existing function instead of own query
    • get rid of the "theme('placeholder')" cruft
    • set a meaningful title
    • moved "$form['sid']" further up, so we don't need to check again
  • workflow_state_add_form_validate()
    • check if 'edit' or 'create'
    • CHECK FOR DUPLICATE STATE NAME (but make sure the supposed duplicate is not the state we're editing)
    • erroneous field now marked with red border
  • workflow_state_add_form_submit()
    • check if 'edit' or 'create'
    • set a watchdog message if 'create'
    • set a specific message
    • consistently use "drupal_goto"
  • workflow_state_delete_form_submit()
    • set a watchdog message
  • workflow_actions_remove_confirm_submit()
    • get rid of the "theme('placeholder')" cruft
    • consistently use "drupal_goto"
  • workflow_deletewf()
    • consistently move watchdog message to workflow_delete_form_submit()
    • consistently use "drupal_goto"
  • workflow_get_state()
    • add as a new function (sure to be needed elsewhere)
  • workflow_cron()
    • get rid of the "theme('placeholder')" cruft

I tested this as much as possible and it worked out very well. Please test it yourself. I expect no new bugs, but if there is a minor one, please commit the patch anyway and tell me what to correct. Rest assured, the total count of bugs will go down with this ;-) Of the rest I'll take care, as I need this module in a perfect condition for a project...

mfredrickson’s picture

Status: Needs review » Fixed

Thanks for all this stuff.

I committed it with two exceptions:

1. Use of return "path/for/user" is preferred to drupal_goto("path/for/user") in _submit hooks.
2. I moved the "Author must have at least 1 transition" message to the validate hook. It makes the most sense here and actually allows users to correct the error before moving on.

Thanks again!

Anonymous’s picture

Status: Fixed » Closed (fixed)