#20801 closed defect (bug) (fixed)
Deprecating PHP4-style constructors gracefully
Reported by: | uuf6429 | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | normal | Version: | 3.2 |
Component: | Widgets | Keywords: | has-patch |
Focuses: | Cc: |
Description (last modified by )
The class WP_Widget in wp-includes/widget.php
makes use of PHP4-style constructor for compatibility with plugins (mostly).
I propose two changes here:
- A direct call to the old constructor should trigger a deprecation notice
- The PHP4-style constructor *must* be declared after
__construct()
otherwise, an E_STRICT regarding constructor re-declaration is thrown.
Please find a patch attached...
Attachments (3)
Change History (13)
#2
@
12 years ago
Related: #16768
These changes look similar to the ones I have in my patched wordpress. That fixes the E_STRICT
error for me, too. I attach my changes merged with yours, I think this needs to be deprecated with the next point release (3.4.0).
Thank you for bringing that issue up, this change went a bit lost on my box.
This is a related test-case: http://codepad.viper-7.com/o9RHpF
#4
@
11 years ago
Cool - temporary I do the patch on my local latest 3.6 nighty built...( moving ph4 call after constructor ) - no annoying message from widget.php. (I also take opportunity to upgrade my oldest plugins using WP_Widget class) - Waiting the next 3.6 nighty built ;-)
M.
#5
@
11 years ago
Not sure I see the reason for deprecating right now. Fixing the E_STRICT sounds good.
#7
@
11 years ago
20801.3.diff swaps the order of the constructors to avoid the E_STRICT notice, but doesn't deprecate the PHP4 one.
#8
@
11 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 24296:
#10
@
10 years ago
Of note, https://wiki.php.net/rfc/remove_php4_constructors PHP 7 is considering the removal of the old style constructor
diff patch