Hello @MikesSite,Is there a way to restrict this to certain forums? Thanks.
Thanks for the reply. I'm not 100% sure what you mean, but I need the ability to exclude certain forums from being able to be ignored.Hello @MikesSite,
I am sure that you can set user group permissions for each forum in the forum category menu which would only allow users with said permissions assigned to ignore such forums selected. If you have any issues setting this up please do not hesitate to reply to this post.
Understood, I have left you a private message to discuss the issue further.Thanks for the reply. I'm not 100% sure what you mean, but I need the ability to exclude certain forums from being able to be ignored.
Bugs Fixed
- Fixed pagination showing up when not needed.
- Fixed missing title attribute.
SELECT thread.thread_id
FROM xf_thread AS thread
LEFT JOIN xf_thread_ignore_th AS thread_ignore ON
(thread.thread_id = thread_ignore.thread_id AND thread_ignore.user_id = '0')
LEFT JOIN xf_forum_ignore_th AS forum_ignore ON
(thread.node_id = forum_ignore.node_id AND forum_ignore.user_id = '0')
Bugs Fixed
- Remove query to fetch ignored content if user is not logged in.
Update released and it will not trigger that query unless the user is logged inOur server was getting an error "Too many connections" and the site went down for about 15 minutes.
Got this email from our server support team:
View attachment 152809
This is the offending code:
(in Class ThemeHouse_IgnoreMore_Extend_XenForo_Model_Thread -> getThreadIdsIgnoredByUser() )
Code:SELECT thread.thread_id FROM xf_thread AS thread LEFT JOIN xf_thread_ignore_th AS thread_ignore ON (thread.thread_id = thread_ignore.thread_id AND thread_ignore.user_id = '0') LEFT JOIN xf_forum_ignore_th AS forum_ignore ON (thread.node_id = forum_ignore.node_id AND forum_ignore.user_id = '0')
Any thoughts on how this can be improved?
EDIT: Looks like this happens when the user isn't logged in. Maybe check for the user's ID > 0 before executing that query?
public function getUnreadThreadIds($userId, array $fetchOptions = array(), $watchedOnly = false)
{
$unreadThreadIds = parent::getUnreadThreadIds($userId, $fetchOptions, $watchedOnly);
$xenOptions = XenForo_Application::get('options');
if ($xenOptions->th_ignoreMore_newPostsShowIgnoredContent) {
return $unreadThreadIds;
}
$ignoredThreadIds = $this->getThreadIdsIgnoredByUser($userId);
return array_diff($unreadThreadIds, $ignoredThreadIds);
}
public function getThreadIdsIgnoredByUser($userId)
{
return $this->_getDb()->fetchCol(
'
SELECT thread.thread_id
FROM xf_thread AS thread
LEFT JOIN xf_thread_ignore_th AS thread_ignore ON
(thread.thread_id = thread_ignore.thread_id AND thread_ignore.user_id = ?)
LEFT JOIN xf_forum_ignore_th AS forum_ignore ON
(thread.node_id = forum_ignore.node_id AND forum_ignore.user_id = ?)
WHERE thread_ignore.ignore_new_posts = 1 OR forum_ignore.ignore_new_posts = 1
', array(
$userId,
$userId
));
}
It's invoked in the same class so just search for `getThreadIdsIgnoredByUser` and you'll see it's now only doing it if there's a user ID presentThe query was taking so long with userId = 0 that it was opening connections and not closing them fast enough, resulting in too many connections on the server. Obviously, any efficiency improvements would be greatly appreciated, as we have thousands of active users every day.
These two blocks are slightly concerning, as they don't seem to take whether the user is logged in into account, either before calling `getThreadIdsIgnoredByUser()`, but I'm not sure if/when this is invoked:
PHP:public function getUnreadThreadIds($userId, array $fetchOptions = array(), $watchedOnly = false) { $unreadThreadIds = parent::getUnreadThreadIds($userId, $fetchOptions, $watchedOnly); $xenOptions = XenForo_Application::get('options'); if ($xenOptions->th_ignoreMore_newPostsShowIgnoredContent) { return $unreadThreadIds; } $ignoredThreadIds = $this->getThreadIdsIgnoredByUser($userId); return array_diff($unreadThreadIds, $ignoredThreadIds); } public function getThreadIdsIgnoredByUser($userId) { return $this->_getDb()->fetchCol( ' SELECT thread.thread_id FROM xf_thread AS thread LEFT JOIN xf_thread_ignore_th AS thread_ignore ON (thread.thread_id = thread_ignore.thread_id AND thread_ignore.user_id = ?) LEFT JOIN xf_forum_ignore_th AS forum_ignore ON (thread.node_id = forum_ignore.node_id AND forum_ignore.user_id = ?) WHERE thread_ignore.ignore_new_posts = 1 OR forum_ignore.ignore_new_posts = 1 ', array( $userId, $userId )); }
Yeah it's not invoked by XenForo but a custom method (you can tell by the XFCP in the class extender and if it's calling the parent method using parent::<methodName> if it's modifying a XenForo add-on).I saw that change, and appreciate that! I was wondering about the function `getUnreadThreadIds()`. I guess that's not invoked by XenForo itself? I'm fairly new to MVC and PHP in general, so sometimes I don't understand what I'm reading!
We use essential cookies to make this site work, and optional cookies to enhance your experience.