1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-12 03:34:15 +01:00

[ticket/15925] Add core.sync_topic_last_post_info_sql

Add event to get more post or user data when syncing
Topic_data is updated with the data from this query, so it needs to be accessed
Custom_fieldnames is merged with fieldnames later, unlike the other event
This keeps the integrity of the core's code

PHPBB3-15925
This commit is contained in:
Alec 2019-01-12 07:06:54 -05:00 committed by Marc Alexander
parent 740b2ffbf2
commit 9ff92f2c36
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995

View File

@ -2072,11 +2072,31 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
unset($delete_topics, $delete_topic_ids);
}
$sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . '
AND u.user_id = p.poster_id';
$result = $db->sql_query($sql);
$sql_ary = array(
'SELECT' => 'p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour',
'FROM' => array(
POSTS_TABLE => 'p',
USERS_TABLE => 'u',
),
'WHERE' => $db->sql_in_set('p.post_id', $post_ids) . '
AND u.user_id = p.poster_id',
);
$custom_fieldnames = array();
/**
* Event to modify the SQL array to get the post and user data from all topics' last posts
*
* @event core.sync_topic_last_post_info_sql
* @var array sql_ary SQL array with some post and user data from the last posts list
* @var array custom_fieldnames Empty array for custom fieldnames to update the topics_table with
* @since 3.2.6-RC1
*/
$vars = array(
'sql_ary',
'custom_fieldnames',
);
extract($phpbb_dispatcher->trigger_event('core.sync_topic_last_post_info_sql', compact($vars)));
$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
while ($row = $db->sql_fetchrow($result))
{
@ -2213,6 +2233,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
// These are fields that will be synchronised
$fieldnames = array('time', 'visibility', 'posts_approved', 'posts_unapproved', 'posts_softdeleted', 'poster', 'first_post_id', 'first_poster_name', 'first_poster_colour', 'last_post_id', 'last_post_subject', 'last_post_time', 'last_poster_id', 'last_poster_name', 'last_poster_colour');
// Add custom fieldnames
$fieldnames = array_merge($fieldnames, $custom_fieldnames);
if ($sync_extra)
{
// This routine assumes that post_reported values are correct