Problem/Motivation

Two endpoints answer with a server error on a site that has the content types and the fields they read, with an empty value in a field that is allowed to be empty and with an ID that came back from storage as what storage returns.

  • The discount listing reads the end date of an offer and calls getTimestamp() on it. The accessor that returns it is declared as returning NULL for an empty field, and an offer without an end date is an ordinary offer, not a broken one.
  • The services list hands a term ID to a method typed int, and entity IDs come back from storage as strings, so the call fails with a TypeError the moment the vocabulary has a term in it.

Neither depends on the site being unusual. The first needs one empty date, the second needs one term.

Proposed resolution

  • Read the date only when there is one, and answer with the empty value where there is not - the same shape the accessor documents.
  • Take the ID as what storage returns it as, and cast where the signature needs a number.
  • Check the rest of the module for the same two shapes: a nullable accessor dereferenced without a check, and an entity ID handed to an int parameter.
  • Cover both with the walk over the endpoints, so a listing on a site that left a field empty is asserted to answer rather than to fail.

Remaining tasks

Everything.

Issue fork myrest-3619483

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:

Comments

sergeydruua created an issue. See original summary.

  • sergeydruua committed 183ef52b on 1.0.x
    Issue #3619483: Read an empty date as empty and take an entity ID as...
sergeydruua’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

sergeydruua’s picture

Status: Fixed » Closed (fixed)