Can you open a ticket on my site so I'll likely need to share an updated build or two to fix the iteration.
Done
Can you open a ticket on my site so I'll likely need to share an updated build or two to fix the iteration.
- When installing or upgrading from a sufficiently older version, only copy the last 2 years of login records from the
xf_iptable into thexf_sv_login_lograther than an unbound number of rows
Thanks for this. This update only took 15 minutes, in testing and in production, for my site. (Compared to the 3.5 hours for my tests of the previous version.)Xon updated Signup abuse detection and blocking with a new update entry:
1.20.8 - Maintenance update
Read the rest of this update entry...
- Fix login/signup log queue did not prune aggressively as they could, and user ganet log pruning didn't trigger
[SignupAbuse] Banning email domains permission, and when rejecting a user it provides an option to ban the email domain.[SignupAbuse] Approving email domains permission, you can add a domain to the known domain list which prevents banning that email domain via the approval queue.
- Fix job to prune user agents used in signups/login didn't run
- Fix {country} replacement variable for unknown country in timezone/language wasn't populated as expected
- Fix XenCentral/MultiSite integration would log an array to string conversion warning on later php versions
Server error log
XF\Db\InvalidQueryException: SV\SignupAbuseBlocking\Job\PruneUserAgentsJob: MySQL statement prepare error [1064]: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 5000' at line 16
src/XF/Db/AbstractStatement.php:225
Generated by: Unknown account
Nov 26, 2026 at 4:02 PM
Stack trace
DELETE ua
FROM xf_sv_user_agent AS ua
WHERE
ua.last_log_date < ?
AND NOT EXISTS(
SELECT 1
FROM xf_sv_signup_log
WHERE ua.user_agent_id = xf_sv_signup_log.user_agent_id
)
AND NOT EXISTS(
SELECT 1
FROM xf_sv_login_log
WHERE ua.user_agent_id = xf_sv_login_log.user_agent_id
)
LIMIT 5000
------------
#0 src/XF/Db/Mysqli/Statement.php(207): XF\Db\AbstractStatement->getException('MySQL statement...', 1064, '42000')
#1 src/XF/Db/Mysqli/Statement.php(43): XF\Db\Mysqli\Statement->getException('MySQL statement...', 1064, '42000')
#2 src/XF/Db/Mysqli/Statement.php(61): XF\Db\Mysqli\Statement->prepare()
#3 src/XF/Db/AbstractAdapter.php(96): XF\Db\Mysqli\Statement->execute()
#4 src/addons/SV/SignupAbuseBlocking/Job/PruneUserAgentsJob.php(43): XF\Db\AbstractAdapter->query('
...', Array)
#5 src/XF/Job/Manager.php(275): SV\SignupAbuseBlocking\Job\PruneUserAgentsJob->run(7.99497)
#6 src/XF/Job/Manager.php(205): XF\Job\Manager->runJobInternal(Array, 7.99497)
#7 src/XF/Job/Manager.php(89): XF\Job\Manager->runJobEntry(Array, 7.99497)
#8 job.php(46): XF\Job\Manager->runQueue(false, 8)
#9 {main}
Request state
array(4) {
["url"] => string(8) "/job.php"
["referrer"] => string(30) "https://forum.bodybuilding.nl/"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
Looks like I used a variation of the delete statement which isn't universally supported. I'll work on fixing thatMariaDB 11.4
- Fix SQL error on when old signup/login records are pruning logged user agents
- Significantly reduce peak memory usage of job that updates the apple relay ips list
logUserAgent() returns an existing user agent's id without updating last_log_date, so last_log_date is effectively the first-seen date. Nearly every user agent older than the cut-off becomes a candidate, including ones still in use.NOT EXISTS against xf_sv_login_log, which has no index on user_agent_id. At best that's a full scan of the login log per 5,000-row batch, every hour.last_log_date when a user agent is reused (at most once a day) and prune on last_log_date alone, or add user_agent_id keys to xf_sv_login_log and xf_sv_signup_log. xf_sv_user_registration_log also references user agents and isn't checked.Pruning the user agent log only happens if the login or signup logs are also pruned.Feature request: a "Delete registration log after X days" option, like the login and signup logs have.
Whatever AI you are using to analyze the code is just wrong.logUserAgent()returns an existing user agent's id without updatinglast_log_date, solast_log_dateis effectively the first-seen date. Nearly every user agent older than the cut-off becomes a candidate, including ones still in use.
$db->insert('xf_sv_user_agent', [
'user_agent' => $userAgent,
'user_agent_hash' => $hash,
'first_log_date' => \XF::$time,
'last_log_date' => \XF::$time,
'count' => 1,
], false, '
last_log_date = GREATEST(last_log_date, values(last_log_date))
, count = count + 1
');
user_agent_hash), the latest last_log_date is updated based on which ever has the latest date (the existing row or the insert query).Pruning the user agent log only happens if the login or signup logs are also pruned.
I'll have a look to see if I can improve the performance the user agent pruning. Missing index should be a simple fix at least.
Whatever AI you are using to analyze the code is just wrong.
When an identical row is added (based offPHP:$db->insert('xf_sv_user_agent', [ 'user_agent' => $userAgent, 'user_agent_hash' => $hash, 'first_log_date' => \XF::$time, 'last_log_date' => \XF::$time, 'count' => 1, ], false, ' last_log_date = GREATEST(last_log_date, values(last_log_date)) , count = count + 1 ');user_agent_hash), the latestlast_log_dateis updated based on which ever has the latest date (the existing row or the insert query).
$userAgentId = (int)$db->fetchOne('
SELECT user_agent_id
FROM xf_sv_user_agent
WHERE user_agent_hash = ? AND user_agent = ?
LIMIT 1
', [$hash, $userAgent]);
if ($userAgentId !== 0)
{
return $userAgentId;
}
ON DUPLICATE KEY UPDATE never runs for it. xf_sv_user_agent also has no unique key on user_agent_hash (only the primary key and keys on first_log_date and last_log_date), so a racing insert can't take the duplicate-key path either.user_agent_id first_seen last_log_date count
208685 2026-10-13 22:04:23 2026-10-13 22:04:23 1
213540 2026-10-23 04:09:22 2026-10-23 04:09:22 1
210448 2026-10-16 22:43:57 2026-10-16 22:43:57 1
224628 2026-11-10 14:37:03 2026-11-10 14:37:03 1
216431 2026-10-28 01:07:07 2026-10-28 01:07:07 1
last_log_date still equals the first-seen date and count is still 1, so once the prune cut-off passes those dates they become prune candidates.user_agent_hash, that SELECT also scans xf_sv_user_agent on every logged login and signup.user_agent_hash the assumption of a single unique row likely does not hold.We use essential cookies to make this site work, and optional cookies to enhance your experience.