Caching (#1894452: caching data locally) is broken:
if (!empty($data['email'])) {
foreach ($data['email'] as $data_email) {
$expire_email = $data_email['appears'] ? $expire : $expire_false;
cache_set("email:{$data_email['value']}", $data_email, 'cache_spambot', $expire_email);
}
}
if (!empty($data['username'])) {
foreach ($data['username'] as $data_username) {
$expire_username = $data_username['appears'] ? $expire : $expire_false;
cache_set("username:{$query['username']}", $data_username, 'cache_spambot', $expire_username);
}
}
if (!empty($data['ip'])) {
$expire_ip = $data['ip']['appears'] ? $expire : $expire_false;
cache_set("ip:{$query['ip']}", $data['ip'], 'cache_spambot', $expire_ip);
}
The structure for 'email' and 'username' is the same as for 'ip'. The foreach's are wrong.
The meaning of $expire vs. $expire_false is unclear and there's no explanation -- it's unclear whether 'ip' is doing the right thing...
Comments
Comment #2
indigoxela commentedAlmost. It's broken, if usernames get checked.
I'm not sure, if anyone's interested (not much activity here), but this is how we fixed it in Backdrop: https://github.com/backdrop-contrib/spambot/issues/1#issuecomment-903258630
The change it needs is relatively small. And the patch might even apply on the D7 version. I didn't try ;-)
BTW: there's a duplicate issue in this queue: https://www.drupal.org/project/spambot/issues/3180665
Or rather, this here is a duplicate but as this one provides a little more info, I decided to post here.
Comment #3
salvisThank you, indigoxela!
So, email would be correct, just not username?
Comment #4
indigoxela commentedYes, that was our finding.
You can easily verify by putting a
debug($data);into function spambot_sfs_request(). Only email is a nested array.Comment #5
magicmyth commentedThis issue seems to now throw a TypeError in newer PHP versions. Attached is a patch porting over the Backdrop fix (https://github.com/backdrop-contrib/spambot/pull/2).
Comment #6
kala4ekComment #8
kala4ek