Problem/Motivation
While attempting to run the update-countries.sh script with an appropriate territories.json file, the resulting CountryManager.php file consisted of country codes mapped to t() verbatim (no country name within quotes) unlike the original CountryManager.php file provided with composer, which is correctly formatted.
This results in the country names being removed from the file and subsequent runs of update-countries.sh file to error on an invalid call to t() in CountryManager.php.
Steps to reproduce
Place the requested territories.json file in DRUPAL_ROOT and run core/scripts/update-countries.sh. The resulting core/lib/Drupal/Core/Locale/CountryManager.php will be "corrupted" with lines such as
'AC' => t(),
instead of
'AC' => t('Ascension Island'),
This was tested with PHP 8.3 and Drupal 10.3.5. The file appears to have the same bug in v11.x too.
Proposed resolution
Line 96 of core/scripts/update-countries.php needs to be changed from
$name = str_contains($name, '\'' ? '"' . $name . '"' : "'" . $name . "'");
to
$name = str_contains($name, '\'') ? '"' . $name . '"' : "'" . $name . "'";
Note the misplaced closing bracket inadvertently wrapping the entire ternary rather than just the two parameters to the str_contains function.
Remaining tasks
User interface changes
N/A
Introduced terminology
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet