Skip to content

Commit

Permalink
Fix address subfield update path without optional modules
Browse files Browse the repository at this point in the history
The subfield settings upgrade path did not take the scenario where the
social_profile_fields module was disabled. We implement the fallback to
act as if the module was disabled and use the default address field
behaviour.
  • Loading branch information
Kingdutch committed Aug 22, 2023
1 parent 0d6e1c0 commit 0069c50
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modules/social_features/social_profile/social_profile.install
Original file line number Diff line number Diff line change
Expand Up @@ -1720,30 +1720,32 @@ function social_profile_update_12018() : void {

$settings = \Drupal::config('social_profile_fields.settings');

// If the field is enabled we use the default address behaviour (no override),
// if the field was disabled then we hide it always.
if ($settings->get('profile_address_field_city')) {
// If the field is enabled, or the setting doesn't exist (e.g. the
// social_profile_fields module isn't enabled), we use the default address
// behaviour (no override),
// If the field was disabled then we hide it always.
if ($settings->get('profile_address_field_city') ?? TRUE) {
unset($field_overrides[AddressField::LOCALITY]);
}
else {
$field_overrides[AddressField::LOCALITY] = FieldOverride::HIDDEN;
}

if ($settings->get('profile_address_field_address')) {
if ($settings->get('profile_address_field_address') ?? TRUE) {
unset($field_overrides[AddressField::ADDRESS_LINE1]);
}
else {
$field_overrides[AddressField::ADDRESS_LINE1] = FieldOverride::HIDDEN;
}

if ($settings->get('profile_address_field_postalcode')) {
if ($settings->get('profile_address_field_postalcode') ?? TRUE) {
unset($field_overrides[AddressField::POSTAL_CODE]);
}
else {
$field_overrides[AddressField::POSTAL_CODE] = FieldOverride::HIDDEN;
}

if ($settings->get('profile_address_field_administrative_area')) {
if ($settings->get('profile_address_field_administrative_area') ?? TRUE) {
unset($field_overrides[AddressField::ADMINISTRATIVE_AREA]);
}
else {
Expand Down

0 comments on commit 0069c50

Please sign in to comment.