| @@ -21,8 +21,10 @@ | ||
| 21 | 21 | $fieldValue = !empty($this->_data[$this->_workflow_condition->field]['value']) ? $this->_data[$this->_workflow_condition->field]['value'] : []; |
| 22 | 22 | if (is_string($fieldValue)) { |
| 23 | 23 | if ('[' === $fieldValue[0] && ']' === $fieldValue[strlen($fieldValue) - 1]) { |
| 24 | 24 | $fieldValue = json_decode($fieldValue); |
| 25 | + } elseif (false !== strpos($fieldValue, BITFORMS_BF_SEPARATOR)) { | |
| 26 | + $fieldValue = explode(BITFORMS_BF_SEPARATOR, $fieldValue); | |
| 25 | 27 | } else { |
| 26 | 28 | $fieldValue = explode(',', $fieldValue); |
| 27 | 29 | } |
| 28 | 30 | } |
| @@ -274,9 +276,8 @@ | ||
| 274 | 276 | foreach ($this->_workflow_condition as $sskey => $ssvalue) { |
| 275 | 277 | if (!is_string($ssvalue)) { |
| 276 | 278 | $this->_workflow_condition = $ssvalue; |
| 277 | 279 | $isCondition = $this->getConditionStatus(); |
| 278 | - | |
| 279 | 280 | if (0 === $sskey) { |
| 280 | 281 | $conditionStatus = $isCondition; |
| 281 | 282 | } |
| 282 | 283 | |
| @@ -297,9 +298,11 @@ | ||
| 297 | 298 | } |
| 298 | 299 | } |
| 299 | 300 | return (bool) $conditionStatus; |
| 300 | 301 | } else { |
| 301 | - $this->_workflow_condition->val = Helper::replaceFieldWithValue($this->_workflow_condition->val, $this->_data); | |
| 302 | + // A month value (2026-01) passes the math evaluator's checks and would come back as 2025. | |
| 303 | + $evalMathExpr = null === $this->dateFieldType(); | |
| 304 | + $this->_workflow_condition->val = Helper::replaceFieldWithValue($this->_workflow_condition->val, $this->_data, $evalMathExpr); | |
| 302 | 305 | |
| 303 | 306 | return $this->isLogicMatch($this->_workflow_condition->logic); |
| 304 | 307 | } |
| 305 | 308 | } |
| @@ -312,8 +315,24 @@ | ||
| 312 | 315 | |
| 313 | 316 | if (!isset($this->_data[$this->_workflow_condition->field])) { |
| 314 | 317 | return false; |
| 315 | 318 | } |
| 319 | + | |
| 320 | + $dateType = $this->dateFieldType(); | |
| 321 | + if (null !== $dateType) { | |
| 322 | + $fieldEntry = $this->_data[$this->_workflow_condition->field]; | |
| 323 | + $dateResult = DateConditionComparator::compare( | |
| 324 | + $logic, | |
| 325 | + isset($fieldEntry['value']) ? $fieldEntry['value'] : '', | |
| 326 | + isset($this->_workflow_condition->val) ? $this->_workflow_condition->val : '', | |
| 327 | + $dateType, | |
| 328 | + isset($fieldEntry['dateFormat']) ? $fieldEntry['dateFormat'] : '' | |
| 329 | + ); | |
| 330 | + if (null !== $dateResult) { | |
| 331 | + return $dateResult; | |
| 332 | + } | |
| 333 | + } | |
| 334 | + | |
| 316 | 335 | switch (strtolower($logic)) { |
| 317 | 336 | case 'equal': |
| 318 | 337 | return self::isEqual(); |
| 319 | 338 | |
| @@ -358,6 +377,19 @@ | ||
| 358 | 377 | |
| 359 | 378 | default: |
| 360 | 379 | return false; |
| 361 | 380 | } |
| 381 | + } | |
| 382 | + | |
| 383 | + /** | |
| 384 | + * @return string|null the condition field's type when it is date-like | |
| 385 | + */ | |
| 386 | + private function dateFieldType() | |
| 387 | + { | |
| 388 | + $field = isset($this->_workflow_condition->field) ? $this->_workflow_condition->field : null; | |
| 389 | + if (!is_string($field) || !isset($this->_data[$field]['type'])) { | |
| 390 | + return null; | |
| 391 | + } | |
| 392 | + $type = $this->_data[$field]['type']; | |
| 393 | + return DateConditionComparator::isDateType($type) ? $type : null; | |
| 362 | 394 | } |
| 363 | 395 | } |