Make WordPress Core

Opened 12 months ago

Closed 11 months ago

Last modified 11 months ago

#58876 closed defect (bug) (fixed)

Calling get_class() without arguments is deprecated in class-wp-http.php

Reported by: ipajen's profile ipajen Owned by: audrasjb's profile audrasjb
Milestone: 6.4 Priority: normal
Severity: normal Version:
Component: HTTP API Keywords: php83 has-patch commit
Focuses: php-compatibility Cc:

Description

Bug Report

Description

When enabling debug the Calling get_class() without arguments is deprecated in class-wp-http.php is shown.

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );
@ini_set( 'display_errors', 1 );
PHP Deprecated:  Calling get_class() without arguments is deprecated in C:\wamp64\www\wordpress\wp-includes\class-wp-http.php on line 329

Environment

  • WordPress: 6.3-RC1
  • PHP: 8.3.0beta1
  • Server: Apache/2.4.54 (Win64) PHP/8.3.0beta1 mod_fcgid/2.3.10-dev
  • Database: mysqli (Server: 8.0.31 / Client: mysqlnd 8.3.0beta1)
  • Browser: Edge 114.0.1823.82 (Windows 10/11)
  • Theme: Twenty Twenty-Three 1.1
  • MU-Plugins: None activated
  • Plugins:
    • Query Monitor 3.13.1
    • WordPress Beta Tester 3.5.2

Attachments (2)

58876.diff (1.2 KB) - added by rajinsharwar 12 months ago.
58876.2.diff (2.2 KB) - added by rajinsharwar 12 months ago.

Download all attachments as: .zip

Change History (18)

This ticket was mentioned in PR #4887 on WordPress/wordpress-develop by @rajinsharwar.


12 months ago
#2

  • Keywords has-patch added

Update class-wp-http.php for PHP warning of the get_class() deprecation.

Trac ticket: https://core.trac.wordpress.org/ticket/58876

@rajinsharwar
12 months ago

#3 @SergeyBiryukov
12 months ago

  • Component changed from General to HTTP API
  • Keywords php81 added; PHP removed

#4 follow-up: @jrf
12 months ago

  • Keywords php83 added; php81 removed

@ipajen You beat me to it. I already have patches ready for this (actually for all known PHP 8.3 issues), but as PHP 8.3 is still in early beta, I wasn't going to pull those until it had stabilized a bit more.

#5 in reply to: ↑ 4 ; follow-up: @ipajen
12 months ago

Replying to jrf:

@ipajen You beat me to it. I already have patches ready for this (actually for all known PHP 8.3 issues), but as PHP 8.3 is still in early beta, I wasn't going to pull those until it had stabilized a bit more.

Yes using 8.3.0beta1 but if I understand it correctly "Calling get_class() without arguments is deprecated" in PHP8.1? Its confusing. Could we try to make WordPress 6.4 beta ready for PHP 8.3? ;) Thanks!

#6 in reply to: ↑ 5 ; follow-up: @jrf
12 months ago

  • Milestone changed from Awaiting Review to 6.4

Replying to ipajen:

Yes using 8.3.0beta1 but if I understand it correctly "Calling get_class() without arguments is deprecated" in PHP8.1? Its confusing.

No, it's not, but it will be deprecated in PHP 8.3.

PHP 7.2 introduced a warning about get_class(null) though, which became a fatal error in PHP 8.0. You might be confused with that ?

https://3v4l.org/GI5Kc#veol

Could we try to make WordPress 6.4 beta ready for PHP 8.3? ;) Thanks!

That's my intention for sure.

#7 in reply to: ↑ 6 ; follow-up: @SergeyBiryukov
12 months ago

Replying to jrf:

Replying to ipajen:

Yes using 8.3.0beta1 but if I understand it correctly "Calling get_class() without arguments is deprecated" in PHP8.1? Its confusing.

No, it's not, but it will be deprecated in PHP 8.3.

PHP 7.2 introduced a warning about get_class(null) though, which became a fatal error in PHP 8.0. You might be confused with that ?

I was confused for a bit here too, because calling get_class() without an argument was proposed for deprecation in PHP 8.1, but apparently did not get enough votes (50/50 split) at the time.

I see now that there is a newer proposal as part of deprecating functions with overloaded signatures, which did get accepted in PHP 8.3. Thanks for the correction :)

Last edited 12 months ago by SergeyBiryukov (previous) (diff)

#8 in reply to: ↑ 7 @jrf
12 months ago

Replying to SergeyBiryukov:

Replying to jrf:

... it will be deprecated in PHP 8.3.

PHP 7.2 introduced a warning about get_class(null) though, which became a fatal error in PHP 8.0. You might be confused with that ?

I was confused for a bit here too, because calling get_class() without an argument was proposed for deprecation in PHP 8.1, but apparently did not get enough votes (50/50 split) at the time.

I see now that there is a newer proposal as part of deprecating functions with overloaded signatures, which did get accepted in PHP 8.3. Thanks for the correction :)

I'd nearly forgotten about that PHP 8.1 vote (as it didn't pass). I try to purge failed RFCs from my memory as soon as I can as otherwise they just confuse me ;-)

If we're talking failed RFCs, get_called_class() was up for deprecation in 7.4 (but got pulled before it went to vote) and there has been discussion about get_class() on an off for years now. I think they finally managed to get it to pass now as enough time has passed since the introduction of the ::class syntax that the bc-break isn't significant enough anymore and what with named parameters not being supported with overloaded signatures, they managed to sway the 2/3s needed for the vote.

@rajinsharwar commented on PR #4887:


12 months ago
#9

Hi @jrfnl, I did that cause I thought that might follow the late static binding concept the most.

@jrf commented on PR #4887:


12 months ago
#10

Hi @jrfnl, I did that cause I thought that might follow the late static binding concept the most.

That's fair, though I wonder if we should allow those methods to be overloaded as there could be potential security implications ?

Then again, strictly speaking static::class is correct to prevent a potential BC-break. If we don't want those methods to be overloaded, they should probably be made final (or the class made final).

This ticket was mentioned in Slack in #hosting by ipajen. View the logs.


12 months ago

This ticket was mentioned in Slack in #core-php by ipajen. View the logs.


12 months ago

#13 @jrf
11 months ago

  • Focuses php-compatibility added
  • Keywords commit added
Version 0, edited 11 months ago by jrf (next)

#14 @audrasjb
11 months ago

  • Owner set to audrasjb
  • Status changed from new to reviewing

#15 @audrasjb
11 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 56495:

HTTP API: Update WP_Http class to avoid PHP deprecation warnings.

This changeset prevents a PHP 8.3 deprecation shown when enabling debug and calling get_class() without arguments.

For more info about this deprecation, see https://wiki.php.net/rfc/deprecate_functions_with_overloaded_signatures#get_class_and_get_parent_class.

Props ipajen, rajinsharwar, SergeyBiryukov, jrf.
Fixes #58876.

Note: See TracTickets for help on using tickets.