I'm getting
Warning: time() expects exactly 0 parameters, 2 given in /var/www/drupal/web/core/lib/Drupal/Core/Field/BaseFieldDefinition.php on line 469

I Found
In "Vote.php" the callback for the BaseFieldDefinition "timestamp" is:
->setDefaultValueCallback('time');

I propose

->setDefaultValueCallback(static::class . '::getRequestTime');

and then

    public static function getRequestTime() {
      return \Drupal::time()->getRequestTime();
    }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

devitate created an issue. See original summary.

devitate’s picture

ndrake86’s picture

Confirming this is an issue w/ any PHP 7.3 based site. The question I have is, is the callback even needed here, "created" is a default provided by core.

ndrake86’s picture

devitate’s picture

I have to agree, I was tripped up by the field name "timeline" or maybe that I was looking at the "media" module which gets creative with "created".

Every other entity works just fine with:


    $fields['created'] = BaseFieldDefinition::create('created')
      ->setLabel(t('Created'))
      ->setDescription(t('The time that the entity was created.'));

ndrake86’s picture

I have to agree, I was tripped up by the field name "timeline" or maybe that I was looking at the "media" module which gets creative with "created".

@devitate If you can test this (or if you already have can we move this to RTBC so that we might be the maintainer to take a look.

devitate’s picture

I get no issues using either patch w/php7.3, so if we're certain that BaseFieldDefinition::create('created') is the equivalent core default then I see no issue, unless "Voting API" has some other reason for using special callback(s).

ndrake86’s picture

Status: Active » Reviewed & tested by the community

I don't see anything special going on here with the timestamp, either solution should work; if there is a need to do something custom the first approach is the right way to go but I'm not seeing that. Hopefully we can get a maintainer to take a look. Moving to RTBC based on the testbot and the previous comment.

pifagor’s picture

Hello everyone.
Soon I'm looking at the patch.

pifagor’s picture

alex_optim’s picture

Looks good.

pifagor’s picture

  • pifagor committed 43d8fb7 on 8.x-3.x authored by ndrake86
    Issue #3048085 by devitate, ndrake86, pifagor, alex_optim: time() is...
pifagor’s picture

Status: Reviewed & tested by the community » Fixed
frmcclurg’s picture

I applied patch "votingapi-timecallback-3048085-1-8.6.patch" and it appears to eliminate the warning message. I am using PHP 7.3.5 Thanks for your help!

destinationsound’s picture

This error also happening in the beta version. This fixed it. Should also be included in the non-dev

Frank Panduh’s picture

Patch Confirmed working on 7.3.
Screenshot Of Patch

Status: Fixed » Closed (fixed)

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