#21865 closed enhancement (fixed)
Audit call time pass by reference usage
| Reported by: | wonderboymusic | Owned by: | ryan |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | General | Version: | |
| Severity: | normal | Keywords: | has-patch do-not-punt |
| Cc: | Focuses: |
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)
#3
@
14 years 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.
#11
@
14 years 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Related #21839