XF 2.3 Validating data on certain events and it's performance implications

Liam C.

Member
Hi there - I am learning and tinkering around with Xenforo Development. I've watched majority of the videos made by Xenforo as well as taken inspiration and guidance from other addons however I have a question.

We are currently considering a custom AutoMod solution - this would essentially validate specific data. For example, when a user were to sign up on our Forums site, we would like to validate whether or not the Date of Birth is a certain date (as we notice majority of our bots go for the exact same Date of Birth).

Another one is to check the content of a message and validating it before sending. So the use case here is to disallow all websites apart from the ones we have whitelisted. I have already set up the options for this, and they output properly, etc.

The issues I am currently facing is on how we can properly access these events when it occur (so 'onThreadSend') as well as whether it has a major performance implication.

Regarding performance implications - I'm also considering using it in certain cases, for example if the user's account is new or without any roles - it performs the check thus reducing any extra queries as they are deemed as unlikely spam.

Many thanks!!
 
The issues I am currently facing is on how we can properly access these events when it occur

It depends on the specific event.

Sometimes it's easier to use a Class extension to hook into an event - sometimes it's easier to use one of the pre-defined code event listeners.

You need to trace through the code that causes the event and identify a good spot to hook into - usually around the point where the action is saved to the database.

whether it has a major performance implication.

Anything that relates to a single infrequent operation (eg user registration), is not going to cause issues.

Anything that relates to an operation by a single user that doesn't affect other users (eg submit a post), is only going to cause issues if your validation process takes significant time to complete - if it causes users to experience a delay when posting - and especially if it actually times out the operation, you're going to get frustrated users and duplicate posts. Be especially cautious if relying on cloud based systems which may cause delays in responses - any API calls you make should have short timeouts and fail gracefully.

Anything that relates to an operation by multiple users that occur frequently (eg reading a post), is something that should be treated very very cautiously - avoid inserting any delays into this process if possible.
 
Back
Top Bottom