[ticket/14234] Use replacement variables instead of references in events

PHPBB3-14234
This commit is contained in:
Marc Alexander 2015-10-12 18:39:29 +02:00
parent a5ab2eb564
commit f90b16df0d
2 changed files with 24 additions and 8 deletions

View file

@ -950,17 +950,21 @@ class acp_forums
$errors = array(); $errors = array();
$forum_data_ary = $forum_data;
/** /**
* Validate the forum data before we create/update the forum * Validate the forum data before we create/update the forum
* *
* @event core.acp_manage_forums_validate_data * @event core.acp_manage_forums_validate_data
* @var array forum_data Array with new forum data * @var array forum_data_ary Array with new forum data
* @var array errors Array of errors, should be strings and not * @var array errors Array of errors, should be strings and not
* language key. * language key.
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.7-RC1 Replaced forum_data with forum_data_ary
*/ */
$vars = array('forum_data', 'errors'); $vars = array('forum_data_ary', 'errors');
extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_validate_data', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_validate_data', compact($vars)));
$forum_data = $forum_data_ary;
unset($forum_data_ary);
if ($forum_data['forum_name'] == '') if ($forum_data['forum_name'] == '')
{ {
@ -1058,18 +1062,22 @@ class acp_forums
} }
unset($forum_data_sql['forum_password_unset']); unset($forum_data_sql['forum_password_unset']);
$forum_data_ary = $forum_data;
/** /**
* Remove invalid values from forum_data_sql that should not be updated * Remove invalid values from forum_data_sql that should not be updated
* *
* @event core.acp_manage_forums_update_data_before * @event core.acp_manage_forums_update_data_before
* @var array forum_data Array with forum data * @var array forum_data_ary Array with forum data
* @var array forum_data_sql Array with data we are going to update * @var array forum_data_sql Array with data we are going to update
* If forum_data_sql[forum_id] is set, we update * If forum_data_sql[forum_id] is set, we update
* that forum, otherwise a new one is created. * that forum, otherwise a new one is created.
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.7-RC1 Replaced forum_data by forum_data_ary
*/ */
$vars = array('forum_data', 'forum_data_sql'); $vars = array('forum_data_ary', 'forum_data_sql');
extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_before', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_before', compact($vars)));
$forum_data = $forum_data_ary;
unset($forum_data_ary);
$is_new_forum = !isset($forum_data_sql['forum_id']); $is_new_forum = !isset($forum_data_sql['forum_id']);
@ -1348,11 +1356,12 @@ class acp_forums
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_EDIT', false, array($forum_data['forum_name'])); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_EDIT', false, array($forum_data['forum_name']));
} }
$forum_data_ary = $forum_data;
/** /**
* Event after a forum was updated or created * Event after a forum was updated or created
* *
* @event core.acp_manage_forums_update_data_after * @event core.acp_manage_forums_update_data_after
* @var array forum_data Array with forum data * @var array forum_data_ary Array with forum data
* @var array forum_data_sql Array with data we updated * @var array forum_data_sql Array with data we updated
* @var bool is_new_forum Did we create a forum or update one * @var bool is_new_forum Did we create a forum or update one
* If you want to overwrite this value, * If you want to overwrite this value,
@ -1360,9 +1369,12 @@ class acp_forums
* @var array errors Array of errors, should be strings and not * @var array errors Array of errors, should be strings and not
* language key. * language key.
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.7-RC1 Replaced forum_data with forum_data_ary
*/ */
$vars = array('forum_data', 'forum_data_sql', 'is_new_forum', 'errors'); $vars = array('forum_data_ary', 'forum_data_sql', 'is_new_forum', 'errors');
extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_after', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_after', compact($vars)));
$forum_data = $forum_data_ary;
unset($forum_data_ary);
return $errors; return $errors;
} }

View file

@ -383,6 +383,7 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
$tpl .= $vars['append']; $tpl .= $vars['append'];
} }
$new_ary = $new;
/** /**
* Overwrite the html code we display for the config value * Overwrite the html code we display for the config value
* *
@ -392,14 +393,17 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
* 1 [optional] => string: size, int: minimum * 1 [optional] => string: size, int: minimum
* 2 [optional] => string: max. length, int: maximum * 2 [optional] => string: max. length, int: maximum
* @var string key Should be used for the id attribute in html * @var string key Should be used for the id attribute in html
* @var array new Array with the config values we display * @var array new_var Array with the config values we display
* @var string name Should be used for the name attribute * @var string name Should be used for the name attribute
* @var array vars Array with the options for the config * @var array vars Array with the options for the config
* @var string tpl The resulting html code we display * @var string tpl The resulting html code we display
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.7-RC1 Replaced new with new_ary
*/ */
$vars = array('tpl_type', 'key', 'new', 'name', 'vars', 'tpl'); $vars = array('tpl_type', 'key', 'new_ary', 'name', 'vars', 'tpl');
extract($phpbb_dispatcher->trigger_event('core.build_config_template', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.build_config_template', compact($vars)));
$new = $new_ary;
unset($new);
return $tpl; return $tpl;
} }