#21865 closed enhancement (fixed)
Audit call time pass by reference usage
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | General | Version: | |
| Severity: | normal | Keywords: | has-patch do-not-punt |
| Cc: |
Description
In PHP 4, it was necessary to use a reference to create a callback that points to the actual object, and not a copy of it. This is no longer the case.
Also, I found more instances of $var = &my_func();. I have not touched any instance of $var1 =&$var2;. All unit tests pass (minus Tests_Theme_WPTheme::test_wp_theme_uris_with_spaces which always fails).
Attachments (1)
Change History (13)
wonderboymusic
— 9 months ago
comment:3
nacin
— 9 months ago
- Keywords do-not-punt added
Some of these may be necessary. For example, I don't think $term = &get_term() will work if get_term() returns null (rather than $null = null). get_term() wasn't changed to return a straight null in #21839, but others might have been.
comment:4
SergeyBiryukov
— 9 months ago
Related: #22013
comment:10
ryan
— 9 months ago
- Resolution set to fixed
- Status changed from assigned to closed
In [22118]:
comment:11
TobiasBg
— 9 months ago
So does this mean that it is now pretty much safe to replace all array( &$this, '...' ) in an add_filter or add_action call in a plugin (that uses a class) with array( $this, '...' )?
Are there reasons not to do this?
I'm asking, because when doing a quick grep through code, I still saw quite a few array( &$this, '...' ) in add_filter or add_action calls not being changed. And as this ticket was closed, they likely won't be.
comment:12
WraithKenny
— 5 weeks ago
Yes you can drop the &
Related #21839