public function attributeExistingVisit($visit, $useClassCache = true)
    {
        if (empty($visit['idvisit'])) {
            $this->logger->debug('Empty idvisit field. Skipping re-attribution..');
            return null;
        }

        $idVisit = $visit['idvisit'];

        if (empty($visit['location_ip'])) {
            $this->logger->debug('Empty location_ip field for idvisit = %s. Skipping re-attribution.', array('idvisit' => $idVisit));
            return null;
        }

        $ip = IPUtils::binaryToStringIP($visit['location_ip']);
        $location = $this->getLocation(array('ip' => $ip), $useClassCache);

        $valuesToUpdate = $this->getVisitFieldsToUpdate($visit, $location);

        if (!empty($valuesToUpdate)) {
            $this->logger->debug('Updating visit with idvisit = {idVisit} (IP = {ip}). Changes: {changes}', array(
                'idVisit' => $idVisit,
                'ip' => $ip,
                'changes' => json_encode($valuesToUpdate)
            ));

            $this->dao->updateVisits($valuesToUpdate, $idVisit);
            $this->dao->updateConversions($valuesToUpdate, $idVisit);
        } else {
            $this->logger->debug('Nothing to update for idvisit = %s (IP = {ip}). Existing location info is same as geolocated.', array(
                'idVisit' => $idVisit,
                'ip' => $ip
            ));
        }

        return $valuesToUpdate;
    }
public function attributeExistingVisit($visit, $useClassCache = true)
    {
        if (empty($visit['idvisit'])) {
            $this->logger->debug('Empty idvisit field. Skipping re-attribution..');
            return null;
        }

        $idVisit = $visit['idvisit'];

        if (empty($visit['location_ip'])) {
            $this->logger->debug('Empty location_ip field for idvisit = %s. Skipping re-attribution.', array('idvisit' => $idVisit));
            return null;
        }

        $ip = IPUtils::binaryToStringIP($visit['location_ip']);
        $location = $this->getLocation(array('ip' => $ip), $useClassCache);

        $valuesToUpdate = $this->getVisitFieldsToUpdate($visit, $location);

        if (!empty($valuesToUpdate)) {
            $this->logger->debug('Updating visit with idvisit = {idVisit} (IP = {ip}). Changes: {changes}', array(
                'idVisit' => $idVisit,
                'ip' => $ip,
                'changes' => json_encode($valuesToUpdate)
            ));

            $this->dao->updateVisits($valuesToUpdate, $idVisit);
            $this->dao->updateConversions($valuesToUpdate, $idVisit);
        } else {
            $this->logger->debug('Nothing to update for idvisit = %s (IP = {ip}). Existing location info is same as geolocated.', array(
                'idVisit' => $idVisit,
                'ip' => $ip
            ));
        }

        return $valuesToUpdate;
    }
public function attributeExistingVisit ( $ visit , $ useClassCache = true ) { if ( empty ( $ visit [ 'idvisit' ] ) ) { $ this -> logger -> debug ( 'Empty idvisit field. Skipping re-attribution..' ) ; return null ; } $ idVisit = $ visit [ 'idvisit' ] ; if ( empty ( $ visit [ 'location_ip' ] ) ) { $ this -> logger -> debug ( 'Empty location_ip field for idvisit = %s. Skipping re-attribution.' , array ( 'idvisit' => $ idVisit ) ) ; return null ; } $ ip = IPUtils :: binaryToStringIP ( $ visit [ 'location_ip' ] ) ; $ location = $ this -> getLocation ( array ( 'ip' => $ ip ) , $ useClassCache ) ; $ valuesToUpdate = $ this -> getVisitFieldsToUpdate ( $ visit , $ location ) ; if ( ! empty ( $ valuesToUpdate ) ) { $ this -> logger -> debug ( 'Updating visit with idvisit = {idVisit} (IP = {ip}). Changes: {changes}' , array ( 'idVisit' => $ idVisit , 'ip' => $ ip , 'changes' => json_encode ( $ valuesToUpdate ) ) ) ; $ this -> dao -> updateVisits ( $ valuesToUpdate , $ idVisit ) ; $ this -> dao -> updateConversions ( $ valuesToUpdate , $ idVisit ) ; } else { $ this -> logger -> debug ( 'Nothing to update for idvisit = %s (IP = {ip}). Existing location info is same as geolocated.' , array ( 'idVisit' => $ idVisit , 'ip' => $ ip ) ) ; } return $ valuesToUpdate ; }
Geolcates an existing visit and then updates it if it's current attributes are different than
what was geolocated. Also updates all conversions of a visit.

**This method should NOT be used from within the tracker.**

@param array $visit The visit information. Must contain an `"idvisit"` element and `"location_ip"` element.
@param bool $useClassCache
@return array|null The visit properties that were updated in the DB mapped to the updated values. If null,
required information was missing from `$visit`.
Geolcates an existing visit and then updates it if it s current attributes are different than what was geolocated . Also updates all conversions of a visit .