The logic in StateItem::getAllowedStates is a bit too optimistic. If the field has a value of an non-existing state (because you changed the workflow while developing) you'll get an PHP error down the lane. I'd suggest to add the current state only if it exists in the list of all states. See attached patch.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stmh created an issue. See original summary.

stmh’s picture

Title: PHP-error when field value as non-existing state » PHP-error when field value has non-existing state
stmh’s picture

Here's the patch

mglaman’s picture

Status: Active » Needs work
Issue tags: -PHP-error when chaning workflow for existing field-values +Needs tests

fixing status.

putting to needs work because we should get a test on this.

stmh’s picture

Status: Needs work » Needs review
FileSize
1.82 KB

Attached is a new patch which adds preliminary tests for getSettableOptions which invoked an PHP error in the old getAllowedValues() function when providing an invalid state-value.

  • bojanz committed 5f087a0 on 8.x-1.x authored by stmh
    Issue #2761265 by stmh: PHP-error when field value has non-existing...
bojanz’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.