From 4bdad7125a34e121f7857c34480d0527c1925384 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 13 Jul 2011 11:32:38 +0200 Subject: [PATCH] [ticket/9608] Remove use of references in captcha and other places References are not really needed in PHP due to copy-on-write. Since PHP5, objects are always passed around as identifiers, which means they are mutable. So it is no longer required to pass these by reference either. PHPBB3-9608 --- phpBB/includes/acp/acp_captcha.php | 10 +++++----- phpBB/includes/auth/auth_db.php | 2 +- phpBB/includes/captcha/captcha_factory.php | 2 +- .../captcha/plugins/phpbb_captcha_gd_plugin.php | 4 ++-- .../captcha/plugins/phpbb_captcha_nogd_plugin.php | 4 ++-- .../captcha/plugins/phpbb_captcha_qa_plugin.php | 4 ++-- .../captcha/plugins/phpbb_recaptcha_plugin.php | 4 ++-- phpBB/includes/ucp/ucp_register.php | 8 ++++---- phpBB/includes/utf/utf_normalizer.php | 10 +++++----- phpBB/memberlist.php | 2 +- phpBB/posting.php | 2 +- phpBB/viewtopic.php | 2 +- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index 8116fce6f0..bef8ae0ea9 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -46,7 +46,7 @@ class acp_captcha // Delegate if ($configure) { - $config_captcha =& phpbb_captcha_factory::get_instance($selected); + $config_captcha = phpbb_captcha_factory::get_instance($selected); $config_captcha->acp_page($id, $this); } else @@ -78,11 +78,11 @@ class acp_captcha // sanity check if (isset($captchas['available'][$selected])) { - $old_captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $old_captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $old_captcha->uninstall(); set_config('captcha_plugin', $selected); - $new_captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $new_captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $new_captcha->install(); add_log('admin', 'LOG_CONFIG_VISUAL'); @@ -113,7 +113,7 @@ class acp_captcha $captcha_select .= ''; } - $demo_captcha =& phpbb_captcha_factory::get_instance($selected); + $demo_captcha = phpbb_captcha_factory::get_instance($selected); foreach ($config_vars as $config_var => $options) { @@ -136,7 +136,7 @@ class acp_captcha { global $db, $user, $config; - $captcha =& phpbb_captcha_factory::get_instance($selected); + $captcha = phpbb_captcha_factory::get_instance($selected); $captcha->init(CONFIRM_REG); $captcha->execute_demo(); diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php index b4ae1911cf..a2ff9b4047 100644 --- a/phpBB/includes/auth/auth_db.php +++ b/phpBB/includes/auth/auth_db.php @@ -129,7 +129,7 @@ function login_db($username, $password, $ip = '', $browser = '', $forwarded_for include ($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); } - $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_LOGIN); $vc_response = $captcha->validate($row); if ($vc_response) diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php index a3766f4054..c2ec8c5bda 100644 --- a/phpBB/includes/captcha/captcha_factory.php +++ b/phpBB/includes/captcha/captcha_factory.php @@ -26,7 +26,7 @@ class phpbb_captcha_factory /** * return an instance of class $name in file $name_plugin.php */ - function &get_instance($name) + function get_instance($name) { global $phpbb_root_path, $phpEx; diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php index add8c3959f..bb76a06371 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_gd_plugin.php @@ -50,9 +50,9 @@ class phpbb_captcha_gd extends phpbb_default_captcha } } - function &get_instance() + function get_instance() { - $instance =& new phpbb_captcha_gd(); + $instance = new phpbb_captcha_gd(); return $instance; } diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php index 490a0d62ab..3e98c45d2c 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_nogd_plugin.php @@ -40,9 +40,9 @@ class phpbb_captcha_nogd extends phpbb_default_captcha } } - function &get_instance() + function get_instance() { - $instance =& new phpbb_captcha_nogd(); + $instance = new phpbb_captcha_nogd(); return $instance; } diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 3bc727da41..272c0cd4d2 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -99,9 +99,9 @@ class phpbb_captcha_qa /** * API function */ - function &get_instance() + function get_instance() { - $instance =& new phpbb_captcha_qa(); + $instance = new phpbb_captcha_qa(); return $instance; } diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index c0db41d5a5..0c36456886 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -54,9 +54,9 @@ class phpbb_recaptcha extends phpbb_default_captcha $this->response = request_var('recaptcha_response_field', ''); } - function &get_instance() + function get_instance() { - $instance =& new phpbb_recaptcha(); + $instance = new phpbb_recaptcha(); return $instance; } diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 71374a9381..293bfb1af9 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -156,13 +156,13 @@ class ucp_register $this->tpl_name = 'ucp_agreement'; return; } - - - // The CAPTCHA kicks in here. We can't help that the information gets lost on language change. + + + // The CAPTCHA kicks in here. We can't help that the information gets lost on language change. if ($config['enable_confirm']) { include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); - $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_REG); } diff --git a/phpBB/includes/utf/utf_normalizer.php b/phpBB/includes/utf/utf_normalizer.php index 52cdf85827..b38c1378d2 100644 --- a/phpBB/includes/utf/utf_normalizer.php +++ b/phpBB/includes/utf/utf_normalizer.php @@ -507,7 +507,7 @@ class utf_normalizer do { - $_utf_len =& $utf_len_mask[$decomp_map[$utf_char][$_pos] & "\xF0"]; + $_utf_len = $utf_len_mask[$decomp_map[$utf_char][$_pos] & "\xF0"]; if (isset($_utf_len)) { @@ -563,7 +563,7 @@ class utf_normalizer do { $c = $decomp_map[$utf_char][$_pos]; - $_utf_len =& $utf_len_mask[$c & "\xF0"]; + $_utf_len = $utf_len_mask[$c & "\xF0"]; if (isset($_utf_len)) { @@ -636,7 +636,7 @@ class utf_normalizer do { $c = $decomp_map[$utf_char][$_pos]; - $_utf_len =& $utf_len_mask[$c & "\xF0"]; + $_utf_len = $utf_len_mask[$c & "\xF0"]; if (isset($_utf_len)) { @@ -717,7 +717,7 @@ class utf_normalizer do { $c = $decomp_map[$utf_char][$_pos]; - $_utf_len =& $utf_len_mask[$c & "\xF0"]; + $_utf_len = $utf_len_mask[$c & "\xF0"]; if (isset($_utf_len)) { @@ -1064,7 +1064,7 @@ class utf_normalizer do { $c = $decomp_map[$utf_char][$_pos]; - $_utf_len =& $utf_len_mask[$c & "\xF0"]; + $_utf_len = $utf_len_mask[$c & "\xF0"]; if (isset($_utf_len)) { diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 685830c656..cbd2e0fcd8 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1528,7 +1528,7 @@ switch ($mode) for ($i = 0, $end = sizeof($user_list); $i < $end; ++$i) { $user_id = $user_list[$i]; - $row =& $id_cache[$user_id]; + $row = $id_cache[$user_id]; $is_leader = (isset($row['group_leader']) && $row['group_leader']) ? true : false; $leaders_set = ($leaders_set || $is_leader); diff --git a/phpBB/posting.php b/phpBB/posting.php index 0809b5a685..74a8ebecb5 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -180,7 +180,7 @@ $user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); if ($config['enable_post_confirm'] && !$user->data['is_registered']) { include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); - $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_POST); } diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index c8768e9ff4..ab58048c86 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1303,7 +1303,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) continue; } - $row =& $rowset[$post_list[$i]]; + $row = $rowset[$post_list[$i]]; $poster_id = $row['user_id']; // End signature parsing, only if needed