Commit 3af7b5cf authored by Steven Ayers's avatar Steven Ayers Committed by Steven Ayers
Browse files

Issue #3318816 by bluegeek9: Update fails to 1.14

parent e5bd0c46
Loading
Loading
Loading
Loading
+22 −16
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ function visitors_update_7131(&$sandbox) {
/**
 * Supports IPv6.
 */
function visitors_update_7140(&$sandbox) {
function visitors_update_7150(&$sandbox) {
  if (!isset($sandbox['progress'])) {
    $sandbox['progress'] = 0;
    $sandbox['last_id'] = 0;
@@ -148,26 +148,31 @@ function visitors_update_7140(&$sandbox) {
      'visitors_ip',
    ))
    ->condition('visitors_id', $sandbox['last_id'], '>')
    ->range(0, 75)
    ->range(0, 100)
    ->orderBy('visitors_id', 'ASC')
    ->execute();

  foreach ($logs as $log) {
    $update = TRUE;
    $ip_address = $log->visitors_ip;
    if (!visitors_is_ip_valid($ip_address)) {
    if (inet_pton($ip_address) != FALSE) {
      $update = FALSE;
    }
    elseif (long2ip($ip_address) != FALSE) {
      $ip_address = long2ip($log->visitors_ip);
    }
    elseif (!$ip_address) {
    elseif (inet_ntop($ip_address) != FALSE) {
      $ip_address = inet_ntop($log->visitors_ip);
    }
    elseif (!$ip_address) {
    else {
      $ip_address = '0.0.0.0';
    }

    if ($update) {
      try {
        db_update('visitors')
          ->fields(array(
          'visitors_ip' => $packed,
            'visitors_ip' => $ip_address,
          ))
          ->condition('visitors_id', $log->visitors_id)
          ->execute();
@@ -175,10 +180,11 @@ function visitors_update_7140(&$sandbox) {
      catch (\Exception $e) {
        watchdog_exception('visitors', $e);
      }
    }

    $sandbox['progress'] += 1;
    $sandbox['last_id'] = $log->visitors_id;
  }
  $sandbox['#finished'] = empty($sandbox['max']) ? 1 : $sandbox['progress'] / $sandbox['max'];

  $sandbox['#finished'] = empty($sandbox['max']) ? 1 : $sandbox['progress'] / $sandbox['max'];
}