From 2f204c25c8af28d6879ac56a3ec47bbe95aa1cf9 Mon Sep 17 00:00:00 2001 From: Ralf Lang Date: Thu, 11 Mar 2021 17:44:50 +0000 Subject: [PATCH] Fix loading countries in non-pear scenarios. See https://github.com/maintaina-com/Nls/tree/pr-autoload-issue This change is backward compatible and should work with the unchanged Nls package no worse than before, with the updated nls package it fixes composer. --- lib/Driver.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Driver.php b/lib/Driver.php index 66fc001b..7498798c 100644 --- a/lib/Driver.php +++ b/lib/Driver.php @@ -2332,7 +2332,12 @@ public function toHash(Horde_Icalendar_Vcard $vcard) $hash[$prefix . 'Address'] .= ' ' . $hash[$prefix . 'PostalCode']; } if (!empty($address[Horde_Icalendar_Vcard::ADR_COUNTRY])) { - include 'Horde/Nls/Countries.php'; + /* Countries */ + if (class_exists(\Horde_Nls_Loader::class)) { + $countries = \Horde_Nls_Loader::loadCountries(); + } else { + include 'Horde/Nls/Countries.php'; + } $country = array_search($address[Horde_Icalendar_Vcard::ADR_COUNTRY], $countries); if ($country === false) { $country = $address[Horde_Icalendar_Vcard::ADR_COUNTRY]; @@ -2932,7 +2937,11 @@ public function fromASContact(Horde_ActiveSync_Message_Contact $message) } /* Countries */ - include 'Horde/Nls/Countries.php'; + if (class_exists(\Horde_Nls_Loader::class)) { + $countries = \Horde_Nls_Loader::loadCountries(); + } else { + include 'Horde/Nls/Countries.php'; + } if (!empty($message->homecountry)) { if (!empty($this->map['homeCountryFree'])) { $hash['homeCountryFree'] = $message->homecountry;