function autofix2() { //check which records were overwritten $logfile = fopen("logfile.txt", "w+"); global $vanshavali; //This check should only run for wifes $spouse = new member($this->data['related_to']); //Check if it is wife if ($spouse->isfemale()) { //Now check if we have different family for the wife here if ($spouse->data['family_id'] == $this->data['family_id']) { $new_family_id = $vanshavali->addfamily($spouse->data['membername']); if ($new_family_id == false) { fwrite($logfile, "Could not add a new family"); fclose($logfile); return; } $spouse->set("family_id", $new_family_id); fwrite($logfile, "{$spouse->id}--corrected" . "\n"); //And we are done. } } fclose($logfile); }