Problem/Motivation

This error occurred in the twig render view block NumericField round must be of type int|float - PHP 8.1.x

Steps to reproduce

render block view by twig with the numeric field in it - using PHP8.1.x

Proposed resolution

We create a patch for this issue, to specify the type.

Issue fork drupal-3338895

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

evonasek created an issue. See original summary.

evonasek’s picture

StatusFileSize
new585 bytes
lendude’s picture

Status: Fixed » Postponed (maintainer needs more info)

@evonasek thanks for reporting your issue.

We only set issues to 'fixed' once they have been committed, so moved this back.

Can you provide example code or steps of how to trigger this with just Drupal core? Often when these issues occur it is due to bad data being supplied by custom code or contrib modules, so we need to be sure that this is an actual bug and not just bad data.

pebosi’s picture

Same bug on my views, having aggregations activated.

Patch works for me.

johnzzon’s picture

Status: Postponed (maintainer needs more info) » Active

I encountered this in a project after upgrading to PHP 8.1 as well.

I tested it in the standard profile installation (no contrib or custom modules).

Steps to reproduce:

  • Enable the Date range module
  • Create a date range field (can be cardinality of 1 or unlimited, doesn't matter) on any content type
  • Create a node and fill the date field
  • Create a view with a page display that lists nodes of the content type
  • Add the date field (I set format to HTML Date)
  • Turn on Aggregation
  • Set Aggregation settings on the field to "Minimum"
  • Save the view
  • Go to the view page and see that the error triggers

Using xdebug, I can see that the $value is a formatted date (eg. 2023-03-09), and I guess it uses NumericField because we use Minimum?
Maybe this is not supported, but I would expect the earliest date to be used when using Minimum.

pebosi’s picture

StatusFileSize
new660 bytes

Updated patch for 10.2

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mortona2k’s picture

Status: Active » Closed (duplicate)
Related issues: +#3302573: PHP8 + MAX aggregation in Views on Date fields throw error

The description and patch in this issue is the same as #3302573.

mortona2k’s picture

Status: Closed (duplicate) » Needs work

Sorry, these are actually a little different, but overlapping. This one addresses invalid numeric field values, the related issue is about date strings, which can cause this error because they're an invalid number. There is a patch in there that has this code, however there is also one that tries to fix the dates as well.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.