diff --git a/src/Controller/Visitors.php b/src/Controller/Visitors.php index dbfaee89e8f1f9ffb6476dd77d3591eafdb5e07c..6146bebe24db5f28ddeff3e129d78ff00723aa3c 100644 --- a/src/Controller/Visitors.php +++ b/src/Controller/Visitors.php @@ -406,10 +406,8 @@ final class Visitors extends ControllerBase { $fields['location_country'] = $location->country->isoCode; $fields['location_region'] = $location->subdivisions[0]->isoCode; $fields['location_city'] = $location->city->names['en']; - $fields['location_postal'] = $location->postal->code; $fields['location_latitude'] = $location->location->latitude; $fields['location_longitude'] = $location->location->longitude; - $fields['location_area_code'] = $location->location->metroCode; } diff --git a/visitors_geoip/src/Service/RebuildLocationService.php b/visitors_geoip/src/Service/RebuildLocationService.php index 5d8d7a685a340288dda5c7d476ef53bb8aaca7d8..c215a4a38bdbe21096590e91ab0c8e6a05f3376a 100644 --- a/visitors_geoip/src/Service/RebuildLocationService.php +++ b/visitors_geoip/src/Service/RebuildLocationService.php @@ -63,10 +63,8 @@ class RebuildLocationService implements VisitorsGeoIpRebuildLocationInterface { $fields['location_country'] = $geoip_data['country_code']; $fields['location_region'] = $geoip_data['region']; $fields['location_city'] = $geoip_data['city']; - $fields['location_postal'] = $geoip_data['postal_code']; $fields['location_latitude'] = $geoip_data['latitude']; $fields['location_longitude'] = $geoip_data['longitude']; - $fields['location_area_code'] = $geoip_data['area_code']; $this->database->update('visitors') ->fields($fields) diff --git a/visitors_geoip/visitors_geoip.install b/visitors_geoip/visitors_geoip.install index 63a1921d91951d9e9ffb4f545e004a272f679da2..02a19f9ab3fa040b40ce28f304de696d2cf9e52e 100644 --- a/visitors_geoip/visitors_geoip.install +++ b/visitors_geoip/visitors_geoip.install @@ -91,18 +91,6 @@ function visitors_geoip_install() { ] ); } - if (!$schema->fieldExists($table, 'location_postal')) { - $schema->addField( - 'visitors', - 'location_postal', - [ - 'type' => 'varchar', - 'length' => 128, - 'not null' => FALSE, - 'default' => NULL, - ] - ); - } if (!$schema->fieldExists($table, 'location_latitude')) { $schema->addField( 'visitors', @@ -127,17 +115,7 @@ function visitors_geoip_install() { ] ); } - if (!$schema->fieldExists($table, 'location_area_code')) { - $schema->addField( - 'visitors', - 'location_area_code', - [ - 'type' => 'int', - 'unsigned' => TRUE, - 'default' => NULL, - ] - ); - } + } /** @@ -148,10 +126,8 @@ function visitors_geoip_uninstall() { $schema = \Drupal::database()->schema(); $schema->dropField($table, 'location_region'); $schema->dropField($table, 'location_city'); - $schema->dropField($table, 'location_postal'); $schema->dropField($table, 'location_latitude'); $schema->dropField($table, 'location_longitude'); - $schema->dropField($table, 'location_area_code'); } /** @@ -2116,3 +2092,19 @@ function visitors_geoip_update_8220(&$sandbox) { Error::logException(\Drupal::logger('visitors'), $e); } } + +/** + * Removes 'location_postal' and 'location_area_code' fields. + */ +function visitors_geoip_update_8222(&$sandbox) { + $table = 'visitors'; + $schema = \Drupal::database()->schema(); + + if ($schema->fieldExists($table, 'location_postal')) { + $schema->dropField($table, 'location_postal'); + } + if ($schema->fieldExists($table, 'location_area_code')) { + $schema->dropField($table, 'location_area_code'); + } + +}