View Full Version : Run "Fix broken user profiles" as a scheduled task
Chaya_
01-20-2015, 05:15 PM
It this possible and how?
Sure is possible, just copy the PHP code of /admincp/misc.php?do=lostusers in a new file, replace "$db->" by "$vbulletin->db->" and upload to /includes/cron/fixprofiles.php, then add a new scheduled task in the admincp which points to that file.
Zachery
01-20-2015, 05:52 PM
You shouldn't be running this task, really ever. What are you doing that you require to run it on a task?
Chaya_
01-20-2015, 05:53 PM
// ###################### Start find lost users #######################
if ($_POST['do'] == 'lostusers')
{
$users = $vbulletin->db->query_read("
SELECT user.userid
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield USING(userid)
WHERE userfield.userid IS NULL
");
$userids = array();
while ($user = $vbulletin->db->fetch_array($users))
{
$userids[] = $user['userid'];
}
if (!empty($userids))
{
/*insert query*/
$vbulletin->db->query_write("INSERT INTO " . TABLE_PREFIX . "userfield (userid) VALUES (" . implode('),(', $userids) . ")");
}
$users = $vbulletin->db->query_read("
SELECT user.userid
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield USING(userid)
WHERE usertextfield.userid IS NULL
");
$userids = array();
while ($user = $vbulletin->db->fetch_array($users))
{
$userids[] = $user['userid'];
}
if (!empty($userids))
{
/*insert query*/
$vbulletin->db->query_write("INSERT INTO " . TABLE_PREFIX . "usertextfield (userid) VALUES (" . implode('),(', $userids) . ")");
}
define('CP_REDIRECT', 'misc.php');
print_stop_message('user_records_repaired');
}
Correct ?
Zachery
01-20-2015, 06:01 PM
Why are you writing users directly into the database instead of using the datamanagers?
Chaya_
01-20-2015, 06:05 PM
I have deactivated my forum registration, i use a other cms to create a account into the forum. i am owner of a gameserver .... if you create a game account, at same time you create a forum account
But the Userprofiles not 100% complete, so i use a cron all 10 minutes, to fix broken user profiles
Paul M
01-20-2015, 06:11 PM
There should never be a need to run that, let alone on a cron.
You should add users properly with the datamanagers, not direct data inserts.
Fix profiles will not fix everything, its designed as a last resort.
Chaya_
01-20-2015, 06:13 PM
i use it ... it is a god way and it work...
Zachery
01-20-2015, 08:53 PM
No, its not a good way. You should fix your scripts to work properly.
ozzy47
01-21-2015, 01:16 AM
I agree, it is not a good way to do it, use the datamanagers as suggested.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.