Skip to:
Content

BuddyPress.org

#8860 closed defect (bug) (fixed)

PHP 8.1.17 - PHP Fatal error: Uncaught TypeError: Unsupported operand types: int - string in bp-core/bp-core-functions.php:1349

Reported by: lenasterg's profile lenasterg Owned by: imath's profile imath
Milestone: 12.0.0 Priority: normal
Severity: normal Version:
Component: Core Keywords: has-patch
Cc:

Description

Hi.
I just updated to PHP 8.1.17 and I get the following Fatal error
PHP Fatal error: Uncaught TypeError: Unsupported operand types: int - string in bp-core/bp-core-functions.php:1349

I managed to solve it by replacing the line 1349

$diff = $r['newer_date'] - $r['older_date'];

with the

$diff = (int)$r['newer_date'] - (int)$r['older_date'];

Please, replace it at the next version.

Thanks again for the great work.

Bests, Lena

Attachments (1)

8860.patch (896 bytes) - added by imath 20 months ago.

Download all attachments as: .zip

Change History (3)

@imath
20 months ago

#1 @imath
20 months ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 12.0.0
  • Severity changed from critical to normal

Hi @lenasterg

Thanks for your report, this is probably due to a plugin using bp_core_time_diff() the wrong way. I've added strict checks about expected arguments to avoid this in 8860.patch.

#2 @imath
20 months ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 13444:

Add stricter argument format check to bp_core_time_diff()

bp_core_time_diff() calculates the time difference between 2 dates formatted as a MySql datetime string or a timestamp. To avoid PHP errors due to a plugin misusing this function, we're now making sure these 2 kinds of format are used before calculating the time difference.

Props lenasterg

Fixes #8860

Note: See TracTickets for help on using tickets.