From fafce88685a59aa97d786bd1efd73dba493ece32 Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Mon, 27 Nov 2023 23:37:36 +0100
Subject: [PATCH] Drop ext-intl in favour of a polyfill

---
 composer.json                           |  3 +-
 composer.lock                           | 90 ++++++++++++++++++++++++-
 docs/simplesamlphp-changelog.md         |  1 +
 docs/simplesamlphp-install.md           |  5 +-
 modules/admin/src/Controller/Config.php |  4 +-
 5 files changed, 96 insertions(+), 7 deletions(-)

diff --git a/composer.json b/composer.json
index 232734c91..b316c03c7 100644
--- a/composer.json
+++ b/composer.json
@@ -48,7 +48,6 @@
         "ext-date": "*",
         "ext-dom": "*",
         "ext-hash": "*",
-        "ext-intl": "*",
         "ext-json": "*",
         "ext-mbstring": "*",
         "ext-openssl": "*",
@@ -73,6 +72,7 @@
         "symfony/http-foundation": "^5.4",
         "symfony/http-kernel": "^5.4",
         "symfony/intl": "^5.4",
+        "symfony/polyfill-intl-icu": "^1.28",
         "symfony/routing": "^5.4",
         "symfony/translation-contracts": "^2.5",
         "symfony/twig-bridge": "^5.4",
@@ -92,6 +92,7 @@
     "suggest": {
         "predis/predis": "Needed if a Redis server is used to store session information",
         "ext-curl": "Needed in order to check for updates automatically",
+        "ext-intl": "Needed if translations for non-English languages are required.",
         "ext-ldap": "Needed if an LDAP backend is used",
         "ext-memcache": "Needed if a Memcache server is used to store session information",
         "ext-pdo": "Needed if a database backend is used, either for authentication or to store session information",
diff --git a/composer.lock b/composer.lock
index 720d33dda..48a0b208b 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "c43f7e35fc2ae24cbc1fe607d74f4d50",
+    "content-hash": "9957bf483505a8b1b9a4203a272491db",
     "packages": [
         {
             "name": "composer/ca-bundle",
@@ -3147,6 +3147,93 @@
             ],
             "time": "2023-01-26T09:26:14+00:00"
         },
+        {
+            "name": "symfony/polyfill-intl-icu",
+            "version": "v1.28.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/polyfill-intl-icu.git",
+                "reference": "e46b4da57951a16053cd751f63f4a24292788157"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/e46b4da57951a16053cd751f63f4a24292788157",
+                "reference": "e46b4da57951a16053cd751f63f4a24292788157",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=7.1"
+            },
+            "suggest": {
+                "ext-intl": "For best performance and support of other locales than \"en\""
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-main": "1.28-dev"
+                },
+                "thanks": {
+                    "name": "symfony/polyfill",
+                    "url": "https://github.com/symfony/polyfill"
+                }
+            },
+            "autoload": {
+                "files": [
+                    "bootstrap.php"
+                ],
+                "psr-4": {
+                    "Symfony\\Polyfill\\Intl\\Icu\\": ""
+                },
+                "classmap": [
+                    "Resources/stubs"
+                ],
+                "exclude-from-classmap": [
+                    "/Tests/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Nicolas Grekas",
+                    "email": "p@tchwork.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony polyfill for intl's ICU-related data and classes",
+            "homepage": "https://symfony.com",
+            "keywords": [
+                "compatibility",
+                "icu",
+                "intl",
+                "polyfill",
+                "portable",
+                "shim"
+            ],
+            "support": {
+                "source": "https://github.com/symfony/polyfill-intl-icu/tree/v1.28.0"
+            },
+            "funding": [
+                {
+                    "url": "https://symfony.com/sponsor",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://github.com/fabpot",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2023-03-21T17:27:24+00:00"
+        },
         {
             "name": "symfony/polyfill-intl-normalizer",
             "version": "v1.28.0",
@@ -6524,7 +6611,6 @@
         "ext-date": "*",
         "ext-dom": "*",
         "ext-hash": "*",
-        "ext-intl": "*",
         "ext-json": "*",
         "ext-mbstring": "*",
         "ext-openssl": "*",
diff --git a/docs/simplesamlphp-changelog.md b/docs/simplesamlphp-changelog.md
index ba56dd6c3..78abb92c4 100644
--- a/docs/simplesamlphp-changelog.md
+++ b/docs/simplesamlphp-changelog.md
@@ -17,6 +17,7 @@ Released 2023-11-28
 * Restore logout-behaviour for IdP's that do not send a saml:NameID in their LogoutRequest (#1894)
 * Fix code error in docs (#1895)
 * Fixed a TypeError when accessing the module.php endpoint without specifying a module (#1907)
+* Drop ext-intl in favour of a polyfill (#1908)
 
 `multiauth`
 
diff --git a/docs/simplesamlphp-install.md b/docs/simplesamlphp-install.md
index 0ed601a1f..606fad7c8 100644
--- a/docs/simplesamlphp-install.md
+++ b/docs/simplesamlphp-install.md
@@ -16,9 +16,10 @@ repository](simplesamlphp-install-repo).
 * A web server capable of executing PHP scripts.
 * PHP version >= 7.4.0.
 * Support for the following PHP extensions:
-  * Always required: `date`, `dom`, `fileinfo`, `filter`, `hash`, `intl`, `json`, `libxml`, `mbstring`, `openssl`,
-                     `pcre`, `session`, `simplexml`, `SPL` and `zlib`
+  * Always required: `date`, `dom`, `fileinfo`, `filter`, `hash`, `json`, `libxml`, `mbstring`, `openssl`,
+                     `pcre`, `session`, `simplexml`, `sodium`, `SPL` and `zlib`
   * When running on Linux: `posix`
+  * When wanting to use translations for non-English languages: `intl`
   * When automatically checking for latest versions, and used by some modules: `cURL`
   * When authenticating against an LDAP server: `ldap`
   * When authenticating against a RADIUS server: `radius`
diff --git a/modules/admin/src/Controller/Config.php b/modules/admin/src/Controller/Config.php
index 8c62dd944..120728fa0 100644
--- a/modules/admin/src/Controller/Config.php
+++ b/modules/admin/src/Controller/Config.php
@@ -245,9 +245,9 @@ class Config
                 ]
             ],
             'intl_get_error_code' => [
-                'required' => 'required',
+                'required' => 'optional',
                 'descr' => [
-                    'required' => Translate::noop('PHP intl extension'),
+                    'optional' => Translate::noop('PHP intl extension'),
                 ]
             ],
             'json_decode' => [
-- 
GitLab