XF 2.0 Extending getDefaultWatchNotifyData in Forum/Thread watcher notifiers


Well-known member
If you wish to inject additional data into the forum/thread notification data, this appears to be very difficult without additional queries.

The problem is the following code construct:
foreach ($finder->fetchColumns(['user_id', 'email_subscribe']) AS $watch)
   $notifyData[$watch['user_id']] = [
      'alert' => true,
      'email' => (bool)$watch['email_subscribe']
(fetchColumns is only used in a handful of places inX F2)

$finder is typed, so ideally this would be moved into a ThreadWatch/ForumWatch filter method. Being able to use closures should make this quite doable, the alternative is replacing the entire function to add a single column, or doing stuff like extending fetchColumns in the finder to stash the data in a side-channel :(

Would this be better under a bug report or a suggestion?


XenForo developer
Staff member
Pretty sure anything here would be a suggestion. Even if we didn't use fetchColumns, to actually change the $notifyData you'd need other changes. Replacing the function is likely to be the realistic solution right now.

Note that not instantiating the entities here is very much intentional as there could be a huge number of records and there would be memory overheads to creating entities (notably with the cache).


Well-known member
@Mike Yeah that makes sense.

I think part of the issue is the fetchPairs exists but there isn't any fetchAllKeyed equivalent. You go from a nice helper function to manually writing your own.

Sadly, I could get away without replacing the function if it wasn't for that explicit bool cast when fetching $watch['email_subscribe'], oh well.