WordPress.org

Make WordPress Core

Opened 8 days ago

Closed 8 days ago

Last modified 8 days ago

#51559 closed defect (bug) (fixed)

PHP 8.0: fix fatal error "Non-static method cannot be called statically"

Reported by: jrf Owned by: SergeyBiryukov
Milestone: 5.6 Priority: normal
Severity: normal Version: trunk
Component: Revisions Keywords: has-patch commit php8
Focuses: coding-standards Cc:

Description

PHP 8 elevates the error level of a number of errors, including the Non-static method cannot be called statically error.
This would previously throw a deprecation warning, but will now throw a fatal error.

In the Text_Diff_Engine_shell::diff() method, the Text_Diff::_getTempDir() method is called statically, which will cause a fatal error in PHP 8.

See: https://3v4l.org/jRJK5

While this is an external library, it is no longer maintained externally, so fixing this in Core by explicitly declaring the Text_Diff::_getTempDir() method as static.

The method doesn't use $this, so changing it to static is safe and is in line with how the method was documented.

Attachments (1)

51559.patch (1.1 KB) - added by jrf 8 days ago.

Download all attachments as: .zip

Change History (5)

@jrf
8 days ago

#2 @SergeyBiryukov
8 days ago

  • Component changed from Text Changes to Revisions

#3 @SergeyBiryukov
8 days ago

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

In 49185:

Revisions: Explicitly declare the Text_Diff::_getTempDir() method as static.

This fixes a "Non-static method cannot be called statically" fatal error on PHP 8.

Props jrf.
Fixes #51559.

#4 @prbot
8 days ago

jrfnl commented on PR #616:

Closing as committed.

Note: See TracTickets for help on using tickets.