-
Improvement
-
Resolution: Fixed
-
Minor
-
3.1.6
-
None
Assume the following code in an extension:
public function mcp_change_poster_after($event)
|
{
|
$userdata = $event['userdata'];
|
$post_info = $event['post_info'];
|
|
$sql = 'UPDATE ' . USERS_TABLE . '
|
SET user_column = user_column - 1
|
WHERE user_id = ' . (int) $post_info['user_id'];
|
$this->db->sql_query($sql);
|
|
$sql = 'UPDATE ' . USERS_TABLE . '
|
SET user_column = user_column + 1
|
WHERE user_id = ' . (int) $userdata['user_id'];
|
$this->db->sql_query($sql);
|
}
|
The mcp_change_poster_after event occurs AFTER this line:
$post_info = phpbb_get_post_data(array($post_id), false, true);
|
This causes an undesirable affect on the event - userdata and post_info are now the same. You can see this by var_dumping the arrays and comparing. So, we need to move the event (otherwise, it's useless).