Bug: Using $origData to track data changes

VOI

Member
Hi,

there seems to be a bug with the $origData function to track data changes:

from time to time a bug occure by using following php code:

Code:
$db = JFactory::getDbo();
$mails = '';
 
// new CCT Leader
$query = "SELECT `md_cct_email` FROM `master_data` WHERE `md_cct_id` = '".$this->data['projects___cct_raw'][0]."'";
$db->setQuery($query);
if($db->query()) {
  $emails = $db->loadColumn();
  foreach($emails as $email)
    $mails.= ",".$email;
}
 
// old CCT Leader
$origData = $formModel->getOrigData();
$db->getquery(true);
$query = "SELECT `md_cct_email` FROM `master_data` WHERE `md_cct_id` = '".$origData[0]->projects___cct_raw."'";
$db->setQuery($query);
if($db->query()) {
  $emails = $db->loadColumn();
  foreach($emails as $email)
    $mails.= ",".$email;
}
 
return ltrim($mails,",");

When bug occures a mail is sent although no data change was performed. Our log files indicates that origData delivers "NULL" although value has been set in data base before. Could you please check?

Unfortunately the bug do not appear in any case and is not reproducable properly.

Best Regards
Michael
 
I can't see a comparison origData - new data.
What do you expect?
Where do you log anything?
 
This really isn't the sort of issue we can help with on a Standard sub, it'd have to be done as custom work on an hourly rate, or perhaps as part of a Pro sub.

I presume you've done a var_dump(...) on your two result sets, to see what they contain?

Also, you haven't told us where you are running this code, i.e. is it a form plugin, or a part of an email template, etc. Which might help us at least give you some suggestions of where to look.

Personally, rather than using origData, as you are already poking around with raw queries, I'd do it all in straight up querying. You could probably mash it all in to one query if you got creative with joining.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top