The entity_created data producer expects $entity->getCreatedTime() to be an int, but is is a string

Created on 7 August 2025, 1 day ago

Problem/Motivation

In the entity_created data producer contains the following code:

      $datetime = new \DateTime();
      $datetime->setTimestamp($entity->getCreatedTime());

$datetime->setTimestamp expects the parameter to be an int value, but $entity->getCreatedTime() returns - to my surprise - a string.

Steps to reproduce

Just use the data producer with a node and a MySQL database.

Proposed resolution

cat returned value of getCreatedTime() to int.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

5.0

Component

Code

Created by

🇩🇪Germany daniel.bosen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @daniel.bosen
  • @danielbosen opened merge request.
  • 🇦🇹Austria klausi 🇦🇹 Vienna

    Thanks, that is surprising! Can you add a test case? Looks like test coverage was missing before, but we should ensure the code is tested.

  • 🇩🇪Germany daniel.bosen

    I do not think, that test coverage is missing, the tests just mock the getCreatedTime() method to return an integer value. This might even be correct for Postgres, not sure. To test this we would need to have functional test with a real database connection.
    But I also could just change the existing test to return a string.

  • 🇦🇹Austria klausi 🇦🇹 Vienna

    Ah ok, I don't think we need a functional test, we can just use a real entity. Can you create a node in the test and use that instead of a mock? We have a database connection available in our kernel tests.

Production build 0.71.5 2024