Avatar

Question about the notification about inactivity for Micha (Technics)

by Auge ⌂, Thursday, May 12, 2022, 18:25 (137 days ago) @ Auge

Hello

I have a next question about the behaviour of the selection of inactive accounts.

The query to select the affected accounts (functions.inc.php, currently line 195) is this one:

 
SELECT
    `user_id`,
    `user_name`,
    `user_email`
FROM `mlf2_userdata`
WHERE `user_lock` = 0
    AND `user_type` = 0
    AND `inactivity_notification` = FALSE
    AND (`last_login` - (NOW() - INTERVAL 3 YEAR)) < 0
ORDER BY `last_login` ASC LIMIT 20;
 

Especially I am interested in AND (`last_login` - (NOW() - INTERVAL 3 YEAR)) < 0. I tested the query part in phpMyAdmin with these two versions. First one with a test_date, that is definitely older than 3 years and the second one with a test_date that is only two years ago.

SELECT '2017-12-30 12:45:40' AS test_date, (NOW() - INTERVAL 3 YEAR) AS old_date, ('2017-12-30 12:45:40' - (NOW() - INTERVAL 3 YEAR)) AS subtraktion
SELECT '2020-12-30 12:45:40' AS test_date, (NOW() - INTERVAL 3 YEAR) AS old_date, ('2020-12-30 12:45:40' - (NOW() - INTERVAL 3 YEAR)) AS subtraktion

These are the results.

2020-12-30 12:45:40  2019-05-12 20:12:31  -20190512199211
2017-12-30 12:45:40  2019-05-12 20:20:15  -20190512199998

In both cases I get a warning.

Warning: #1292 Falscher DOUBLE-Wert gekürzt: '2017-12-30 12:45:40'
/* free translation: shortened wrong DOUBLE value: */

I think, the logic of the condition is broken. The condition AND (`last_login` - (NOW() - INTERVAL 3 YEAR)) < 0 returns a negative value (< 0) (and is therefore TRUE) in every single case. But that's a task for tomorrow.

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!


Complete thread:

 RSS Feed of thread