mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-01 11:14:36 +00:00
Remove lingering instances of call time pass-by-reference, limited to instances of callable - use $this instead of &$this.
Props jdgrimes. See #25160. git-svn-id: https://develop.svn.wordpress.org/trunk@25254 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -133,8 +133,8 @@ class testXMLParser {
|
||||
$this->xml = xml_parser_create();
|
||||
xml_set_object($this->xml, $this);
|
||||
xml_parser_set_option($this->xml,XML_OPTION_CASE_FOLDING, 0);
|
||||
xml_set_element_handler($this->xml, array(&$this, 'startHandler'), array(&$this, 'endHandler'));
|
||||
xml_set_character_data_handler($this->xml, array(&$this, 'dataHandler'));
|
||||
xml_set_element_handler($this->xml, array($this, 'startHandler'), array($this, 'endHandler'));
|
||||
xml_set_character_data_handler($this->xml, array($this, 'dataHandler'));
|
||||
$this->parse($in);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class WPProfiler {
|
||||
|
||||
if (!$this->stack) {
|
||||
// log all actions and filters
|
||||
add_filter('all', array(&$this, 'log_filter'));
|
||||
add_filter('all', array($this, 'log_filter'));
|
||||
}
|
||||
|
||||
// reset the wpdb queries log, storing it on the profile stack if necessary
|
||||
@@ -101,7 +101,7 @@ class WPProfiler {
|
||||
}
|
||||
|
||||
if (!$this->stack) {
|
||||
remove_filter('all', array(&$this, 'log_filter'));
|
||||
remove_filter('all', array($this, 'log_filter'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
||||
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
|
||||
$GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
|
||||
|
||||
add_filter('theme_root', array(&$this, '_theme_root'));
|
||||
add_filter( 'stylesheet_root', array(&$this, '_theme_root') );
|
||||
add_filter( 'template_root', array(&$this, '_theme_root') );
|
||||
add_filter('theme_root', array($this, '_theme_root'));
|
||||
add_filter( 'stylesheet_root', array($this, '_theme_root') );
|
||||
add_filter( 'template_root', array($this, '_theme_root') );
|
||||
|
||||
// clear caches
|
||||
wp_clean_themes_cache();
|
||||
@@ -21,9 +21,9 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
||||
|
||||
function tearDown() {
|
||||
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
|
||||
remove_filter('theme_root', array(&$this, '_theme_root'));
|
||||
remove_filter( 'stylesheet_root', array(&$this, '_theme_root') );
|
||||
remove_filter( 'template_root', array(&$this, '_theme_root') );
|
||||
remove_filter('theme_root', array($this, '_theme_root'));
|
||||
remove_filter( 'stylesheet_root', array($this, '_theme_root') );
|
||||
remove_filter( 'template_root', array($this, '_theme_root') );
|
||||
|
||||
wp_clean_themes_cache();
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
|
||||
@@ -12,7 +12,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$tag = rand_str();
|
||||
$val = rand_str();
|
||||
|
||||
add_filter($tag, array(&$a, 'filter'));
|
||||
add_filter($tag, array($a, 'filter'));
|
||||
$this->assertEquals($val, apply_filters($tag, $val));
|
||||
|
||||
// only one event occurred for the hook, with empty args
|
||||
@@ -29,7 +29,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$tag = rand_str();
|
||||
$val = rand_str();
|
||||
|
||||
add_filter($tag, array(&$a, 'filter'));
|
||||
add_filter($tag, array($a, 'filter'));
|
||||
$this->assertEquals($val, apply_filters($tag, $val));
|
||||
|
||||
// make sure our hook was called correctly
|
||||
@@ -37,7 +37,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$this->assertEquals(array($tag), $a->get_tags());
|
||||
|
||||
// now remove the filter, do it again, and make sure it's not called this time
|
||||
remove_filter($tag, array(&$a, 'filter'));
|
||||
remove_filter($tag, array($a, 'filter'));
|
||||
$this->assertEquals($val, apply_filters($tag, $val));
|
||||
$this->assertEquals(1, $a->get_call_count());
|
||||
$this->assertEquals(array($tag), $a->get_tags());
|
||||
@@ -66,8 +66,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$val = rand_str();
|
||||
|
||||
// add both filters to the hook
|
||||
add_filter($tag, array(&$a1, 'filter'));
|
||||
add_filter($tag, array(&$a2, 'filter'));
|
||||
add_filter($tag, array($a1, 'filter'));
|
||||
add_filter($tag, array($a2, 'filter'));
|
||||
|
||||
$this->assertEquals($val, apply_filters($tag, $val));
|
||||
|
||||
@@ -82,7 +82,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$val = rand_str();
|
||||
$arg1 = rand_str();
|
||||
|
||||
add_filter($tag, array(&$a, 'filter'), 10, 2);
|
||||
add_filter($tag, array($a, 'filter'), 10, 2);
|
||||
// call the filter with a single argument
|
||||
$this->assertEquals($val, apply_filters($tag, $val, $arg1));
|
||||
|
||||
@@ -99,8 +99,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$arg2 = rand_str();
|
||||
|
||||
// a1 accepts two arguments, a2 doesn't
|
||||
add_filter($tag, array(&$a1, 'filter'), 10, 3);
|
||||
add_filter($tag, array(&$a2, 'filter'));
|
||||
add_filter($tag, array($a1, 'filter'), 10, 3);
|
||||
add_filter($tag, array($a2, 'filter'));
|
||||
// call the filter with two arguments
|
||||
$this->assertEquals($val, apply_filters($tag, $val, $arg1, $arg2));
|
||||
|
||||
@@ -119,8 +119,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$val = rand_str();
|
||||
|
||||
// make two filters with different priorities
|
||||
add_filter($tag, array(&$a, 'filter'), 10);
|
||||
add_filter($tag, array(&$a, 'filter2'), 9);
|
||||
add_filter($tag, array($a, 'filter'), 10);
|
||||
add_filter($tag, array($a, 'filter2'), 9);
|
||||
$this->assertEquals($val, apply_filters($tag, $val));
|
||||
|
||||
// there should be two events, one per filter
|
||||
@@ -151,7 +151,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$val = rand_str();
|
||||
|
||||
// add an 'all' filter
|
||||
add_filter('all', array(&$a, 'filterall'));
|
||||
add_filter('all', array($a, 'filterall'));
|
||||
// do some filters
|
||||
$this->assertEquals($val, apply_filters($tag1, $val));
|
||||
$this->assertEquals($val, apply_filters($tag2, $val));
|
||||
@@ -163,8 +163,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
// the right hooks should have been called in order
|
||||
$this->assertEquals(array($tag1, $tag2, $tag1, $tag1), $a->get_tags());
|
||||
|
||||
remove_filter('all', array(&$a, 'filterall'));
|
||||
$this->assertFalse( has_filter('all', array(&$a, 'filterall')) );
|
||||
remove_filter('all', array($a, 'filterall'));
|
||||
$this->assertFalse( has_filter('all', array($a, 'filterall')) );
|
||||
|
||||
}
|
||||
|
||||
@@ -173,9 +173,9 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$tag = rand_str();
|
||||
$val = rand_str();
|
||||
|
||||
add_filter('all', array(&$a, 'filterall'));
|
||||
add_filter('all', array($a, 'filterall'));
|
||||
$this->assertTrue( has_filter('all') );
|
||||
$this->assertEquals( 10, has_filter('all', array(&$a, 'filterall')) );
|
||||
$this->assertEquals( 10, has_filter('all', array($a, 'filterall')) );
|
||||
$this->assertEquals($val, apply_filters($tag, $val));
|
||||
|
||||
// make sure our hook was called correctly
|
||||
@@ -183,8 +183,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$this->assertEquals(array($tag), $a->get_tags());
|
||||
|
||||
// now remove the filter, do it again, and make sure it's not called this time
|
||||
remove_filter('all', array(&$a, 'filterall'));
|
||||
$this->assertFalse( has_filter('all', array(&$a, 'filterall')) );
|
||||
remove_filter('all', array($a, 'filterall'));
|
||||
$this->assertFalse( has_filter('all', array($a, 'filterall')) );
|
||||
$this->assertFalse( has_filter('all') );
|
||||
$this->assertEquals($val, apply_filters($tag, $val));
|
||||
// call cound should remain at 1
|
||||
@@ -200,7 +200,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$a = new MockAction();
|
||||
$tag = rand_str();
|
||||
|
||||
add_action($tag, array(&$a, 'filter'));
|
||||
add_action($tag, array($a, 'filter'));
|
||||
|
||||
apply_filters_ref_array($tag, array(&$obj));
|
||||
|
||||
@@ -220,8 +220,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$b = new MockAction();
|
||||
$tag = rand_str();
|
||||
|
||||
add_action($tag, array(&$a, 'filter_append'), 10, 2);
|
||||
add_action($tag, array(&$b, 'filter_append'), 10, 2);
|
||||
add_action($tag, array($a, 'filter_append'), 10, 2);
|
||||
add_action($tag, array($b, 'filter_append'), 10, 2);
|
||||
|
||||
$result = apply_filters_ref_array($tag, array('string', &$obj));
|
||||
|
||||
@@ -242,7 +242,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function _self_removal($tag) {
|
||||
remove_action( $tag, array(&$this, '_self_removal'), 10, 1 );
|
||||
remove_action( $tag, array($this, '_self_removal'), 10, 1 );
|
||||
return $tag;
|
||||
}
|
||||
|
||||
@@ -254,9 +254,9 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$a = new MockAction();
|
||||
$b = new MockAction();
|
||||
|
||||
add_action( $tag, array(&$a, 'filter_append'), 11, 1 );
|
||||
add_action( $tag, array(&$b, 'filter_append'), 12, 1 );
|
||||
add_action( $tag, array(&$this, '_self_removal'), 10, 1 );
|
||||
add_action( $tag, array($a, 'filter_append'), 11, 1 );
|
||||
add_action( $tag, array($b, 'filter_append'), 12, 1 );
|
||||
add_action( $tag, array($this, '_self_removal'), 10, 1 );
|
||||
|
||||
$result = apply_filters($tag, $tag);
|
||||
$this->assertEquals( 1, $a->get_call_count(), 'priority 11 filters should run after priority 10 empties itself' );
|
||||
|
||||
@@ -19,7 +19,7 @@ class Tests_Meta extends WP_UnitTestCase {
|
||||
$meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' );
|
||||
$this->assertEquals( 'unsanitized', $meta );
|
||||
|
||||
register_meta( 'post', 'some_meta', array( &$this, '_meta_sanitize_cb' ) );
|
||||
register_meta( 'post', 'some_meta', array( $this, '_meta_sanitize_cb' ) );
|
||||
$meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' );
|
||||
$this->assertEquals( 'sanitized', $meta );
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase {
|
||||
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
|
||||
$GLOBALS['wp_theme_directories'] = array( $this->theme_root );
|
||||
|
||||
add_filter('theme_root', array(&$this, '_theme_root'));
|
||||
add_filter( 'stylesheet_root', array(&$this, '_theme_root') );
|
||||
add_filter( 'template_root', array(&$this, '_theme_root') );
|
||||
add_filter('theme_root', array($this, '_theme_root'));
|
||||
add_filter( 'stylesheet_root', array($this, '_theme_root') );
|
||||
add_filter( 'template_root', array($this, '_theme_root') );
|
||||
// clear caches
|
||||
wp_clean_themes_cache();
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
@@ -20,9 +20,9 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase {
|
||||
|
||||
function tearDown() {
|
||||
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
|
||||
remove_filter('theme_root', array(&$this, '_theme_root'));
|
||||
remove_filter( 'stylesheet_root', array(&$this, '_theme_root') );
|
||||
remove_filter( 'template_root', array(&$this, '_theme_root') );
|
||||
remove_filter('theme_root', array($this, '_theme_root'));
|
||||
remove_filter( 'stylesheet_root', array($this, '_theme_root') );
|
||||
remove_filter( 'template_root', array($this, '_theme_root') );
|
||||
wp_clean_themes_cache();
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
parent::tearDown();
|
||||
|
||||
@@ -15,9 +15,9 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
// /themes is necessary as theme.php functions assume /themes is the root if there is only one root.
|
||||
$GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
|
||||
|
||||
add_filter('theme_root', array(&$this, '_theme_root'));
|
||||
add_filter( 'stylesheet_root', array(&$this, '_theme_root') );
|
||||
add_filter( 'template_root', array(&$this, '_theme_root') );
|
||||
add_filter('theme_root', array($this, '_theme_root'));
|
||||
add_filter( 'stylesheet_root', array($this, '_theme_root') );
|
||||
add_filter( 'template_root', array($this, '_theme_root') );
|
||||
// clear caches
|
||||
wp_clean_themes_cache();
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
@@ -25,9 +25,9 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
|
||||
function tearDown() {
|
||||
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
|
||||
remove_filter('theme_root', array(&$this, '_theme_root'));
|
||||
remove_filter( 'stylesheet_root', array(&$this, '_theme_root') );
|
||||
remove_filter( 'template_root', array(&$this, '_theme_root') );
|
||||
remove_filter('theme_root', array($this, '_theme_root'));
|
||||
remove_filter( 'stylesheet_root', array($this, '_theme_root') );
|
||||
remove_filter( 'template_root', array($this, '_theme_root') );
|
||||
wp_clean_themes_cache();
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
parent::tearDown();
|
||||
|
||||
@@ -508,7 +508,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
|
||||
$this->assertFalse( $admin->has_cap('add_post_meta', $post, '_protected') );
|
||||
$this->assertFalse( $admin->has_cap('delete_post_meta', $post, '_protected') );
|
||||
|
||||
register_meta( 'post', '_protected', array( &$this, '_meta_filter' ), array( &$this, '_meta_yes_you_can' ) );
|
||||
register_meta( 'post', '_protected', array( $this, '_meta_filter' ), array( $this, '_meta_yes_you_can' ) );
|
||||
$this->assertTrue( $admin->has_cap('edit_post_meta', $post, '_protected') );
|
||||
$this->assertTrue( $admin->has_cap('add_post_meta', $post, '_protected') );
|
||||
$this->assertTrue( $admin->has_cap('delete_post_meta', $post, '_protected') );
|
||||
@@ -517,7 +517,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
|
||||
$this->assertTrue( $admin->has_cap('add_post_meta', $post, 'not_protected') );
|
||||
$this->assertTrue( $admin->has_cap('delete_post_meta', $post, 'not_protected') );
|
||||
|
||||
register_meta( 'post', 'not_protected', array( &$this, '_meta_filter' ), array( &$this, '_meta_no_you_cant' ) );
|
||||
register_meta( 'post', 'not_protected', array( $this, '_meta_filter' ), array( $this, '_meta_no_you_cant' ) );
|
||||
$this->assertFalse( $admin->has_cap('edit_post_meta', $post, 'not_protected') );
|
||||
$this->assertFalse( $admin->has_cap('add_post_meta', $post, 'not_protected') );
|
||||
$this->assertFalse( $admin->has_cap('delete_post_meta', $post, 'not_protected') );
|
||||
|
||||
Reference in New Issue
Block a user