Problem/Motivation

The isEmpty method (\Drupal\office_hours\Element\OfficeHoursDatetime::isEmpty) fails on a -1 value. It checks for a string '-1' but sometimes it gets the -1 integer and doesn't mark that as empty.

Steps to reproduce

(using the dev release) I added a field to a node, with the exceptions. After adding an item and exception, I re-edited the node and removed the exception. Upon saving, there are a lot of form-errors: This value should be of the correct primitive type.

Proposed resolution

Change the check to if ((int) $element === -1) { ... }

Remaining tasks

-

User interface changes

-

API changes

-

Data model changes

-

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SpadXIII created an issue. See original summary.

johnv’s picture

Status: Active » Needs review
johnv’s picture

Title: isEmpty check fails for empty exceptions » Incorrect isEmpty() check for some empty exceptions

  • johnv committed 8def0fe on 8.x-1.x
    Issue #3253749 by SpadXIII: Incorrect isEmpty() check for some empty...
johnv’s picture

Title: Incorrect isEmpty() check for some empty exceptions » Incorrect isEmpty() check for some empty Exception days
Version: 8.x-1.x-dev » 8.x-1.5
Status: Needs review » Fixed

Thanks, fixed in a slightly different version.

  • johnv committed 5343d78 on 8.x-1.x
    Issue #3253749 by SpadXIII: Incorrect isEmpty() check for some empty...

Status: Fixed » Closed (fixed)

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

johnv’s picture

Status: Closed (fixed) » Active

  • johnv committed 33c71cb on 8.x-1.x
    Issue #3253749: Incorrect isEmpty() check for some empty Exception days...
johnv’s picture

Status: Active » Fixed

The tests/src/Unit/OfficeHoursDatetimeUnitTest.php was fixed in above commit.

Status: Fixed » Closed (fixed)

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