Marcel
Active member
I have a daily cron job that calculates a user's postings in one set of forums over another to work out a ratio.
There's a daily cron job that runs calculating this, and then writing the resulting integer to the user's profile in a custom field.
During the automatic run, most users get updated. However some don't. They just don't get recalculated and the profiles updated.
If I then run the cron job manually it calculates the postcount correctly.
I can't understand why it would be different if I'm running the cron job manually? Which part would be in question, would it be the actual cron code, the model code, datawriter?
Here's the relevant part of the cron code (This bit is per user, it's inside a loop)
Here's the function in the DataWriter that writes to the profile
I do have my own custom _preSave in the DataWriter
IIRC I had to do that to take out the checks when saving as it was throwing up validation errors.
Any thoughts?
There's a daily cron job that runs calculating this, and then writing the resulting integer to the user's profile in a custom field.
During the automatic run, most users get updated. However some don't. They just don't get recalculated and the profiles updated.
If I then run the cron job manually it calculates the postcount correctly.
I can't understand why it would be different if I'm running the cron job manually? Which part would be in question, would it be the actual cron code, the model code, datawriter?
Here's the relevant part of the cron code (This bit is per user, it's inside a loop)
Code:
$customFields = unserialize($userProfile['custom_fields']);
$customFields['mab_mod_cr'] = $ratio;
$dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
$dw->writeRatioToProfile($userProfile,$customFields);
$changedFields = array();
$changedFields['mab_mod_cr'] = array($ratio,$ratio);
$userModel->logChanges($userId,$changedFields,'1');
Here's the function in the DataWriter that writes to the profile
Code:
public function writeRatioToProfile($userProfile, $customFields)
{
$this->setExistingData($userProfile);
$this->setOption(XenForo_DataWriter_User::OPTION_ADMIN_EDIT, true);
$this->setCustomFields($customFields);
$this->rebuildCustomFields();
$this->save();
return;
}
I do have my own custom _preSave in the DataWriter
Code:
protected function _preSave()
{
return;
}
IIRC I had to do that to take out the checks when saving as it was throwing up validation errors.
Any thoughts?