#33933 closed defect (bug) (invalid)
Avoid PHP 4 warnings for PHP 5
Reported by: | nmeiser | Owned by: | |
---|---|---|---|
Milestone: | Priority: | lowest | |
Severity: | trivial | Version: | 4.3 |
Component: | Widgets | Keywords: | |
Focuses: | Cc: |
Description
wp-includes/widgets.php
No more warnings or errors for the right use of $this->WP_Widget to create a new object of the class WP_Widget with PHP 5.
The old helper constructor method WP_Widget() is only for PHP 4, so only those guys should get a deprecated warning/error message!!
!!Please check all implementations of _deprecated_constructor in the methods that are named like the class name inside the wordpress project!!
$php_version is not working at this place!
Attachments (1)
Change History (4)
#1
@
9 years ago
- Milestone Awaiting Review deleted
- Priority changed from normal to lowest
- Resolution set to invalid
- Severity changed from normal to trivial
- Status changed from new to closed
Thanks for the patch, nmeiser.
There's no circumstance under which a user would ever see this error message. The minimum version of PHP that WordPress supports is 5.2.4. If a user is running PHP 4, they won't be able to install WordPress, and if they've upgraded from an (extremely) old version of WordPress then they'll simply be presented with an error message stating that their PHP version is too old.
If I'm wrong, please let me know, but ensuring compatibility with software that's over 11 years old is not a priority.
#2
follow-up:
↓ 3
@
9 years ago
Well, then tell me why I have to see the warning message with php 5.4.12, so that I can't navigate through the backend because menu jumps down to not scrollable area?
The helper methode "function classname()" is only used for having a constructor() methode for php 4.
When plugins use $this->WP_Widget(....) it's totally ok and not php4 style!
If Wordpress will not allow PHP4 than remove the methode!!
Priority should be to write proper software and remove old stuff that is not needed or will you keep it for the next 11 years?
#3
in reply to:
↑ 2
@
9 years ago
I may misunderstand your point, but ...
Replying to nmeiser:
Well, then tell me why I have to see the warning message with php 5.4.12, so that I can't navigate through the backend because menu jumps down to not scrollable area?
If you see them it's because
- You have a theme or a plugin that use the deprecated function, and
- Your PHP environment is set up with ini directive
display_errors
set to on
Contact the author of the offending plugin and/or display_errors
to off either in your host's server configuration for PHP, .htaccess
, php.ini
, .user.ini
or wp-config.php
.
Errors should not be displayed on sites "in production". If you need them, set up PHP error_log
or use WP_DEBUG
with error logging. Errors and warnings are for developers, not users.
When plugins use $this->WP_Widget(....) it's totally ok and not php4 style!
Yes, it's legal in PHP 5 for BC reasons since __construct()
was introduced. No, it's not ok because WordPress may have to remove the function in a future release because it, accordong to the PHP roadmap, som day will not work with the latest PHP.
If Wordpress will not allow PHP4 than remove the methode!!
That could lead to fatal errors and break sites. Deprecation is telling developers to stop using the method.
See https://make.wordpress.org/core/2015/07/02/deprecating-php4-style-constructors-in-wordpress-4-3/
Patchfile for wp-includes/widgets.php