[ticket/12718] Use remove_topic_from_statistic() for delete_topic

https://tracker.phpbb.com/browse/PHPBB3-12718
https://tracker.phpbb.com/browse/PHPBB3-12737
PHPBB3-12718
PHPBB3-12737
Use a variable for the query