#58876 closed defect (bug) (fixed)
Calling get_class() without arguments is deprecated in class-wp-http.php
Reported by: | ipajen | Owned by: | 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)
Change History (18)
This ticket was mentioned in PR #4887 on WordPress/wordpress-develop by @rajinsharwar.
16 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
#4
follow-up:
↓ 5
@
16 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:
↓ 6
@
16 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:
↓ 7
@
16 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 ?
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:
↓ 8
@
16 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 :)
#8
in reply to:
↑ 7
@
16 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:
16 months ago
#9
Hi @jrfnl, I did that cause I thought that might follow the late static binding concept the most.
16 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.
15 months ago
This ticket was mentioned in Slack in #core-php by ipajen. View the logs.
15 months ago
#13
@
15 months ago
- Focuses php-compatibility added
- Keywords commit added
Related to: https://core.trac.wordpress.org/ticket/59231
@audrasjb commented on PR #4887:
14 months ago
#16
committed in https://core.trac.wordpress.org/changeset/56495
https://wiki.php.net/rfc/deprecations_php_8_1