From b5eee010a7f4ea6a4f46aab2fc06437d9e674d0c Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 13 Nov 2026 01:25:46 +0100 Subject: [PATCH 1/2] Add the update guide for 5.0 Several 5.x changes need an entry in the update guide. Creating the file once keeps them from conflicting over its creation. Co-Authored-By: Claude Opus 5.5 --- docs/index.md | 1 + docs/v4-to-v5-update.md | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 docs/v4-to-v5-update.md diff --git a/docs/index.md b/docs/index.md index c87f1b49..b0b9f85c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1 +1,2 @@ * [Overview](overview.md) +* [Updating from v4 to v5](v4-to-v5-update.md) diff --git a/docs/v4-to-v5-update.md b/docs/v4-to-v5-update.md new file mode 100644 index 00000000..e40b0a64 --- /dev/null +++ b/docs/v4-to-v5-update.md @@ -0,0 +1,3 @@ +## Updating from v4 to v5 + +The following changes were made to the String package between version 4 and version 5. From 78ab4748f36152b38d9e8e7b399fcc8ccae5903e Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 13 Nov 2026 01:27:06 +0100 Subject: [PATCH 2/2] Remove the default_charset side effect of StringHelper Loading StringHelper.php changed the process-wide default_charset setting, depending on whether some code had loaded the class yet. The side effect was deprecated in 4.x; UTF-8 has been PHP's default since 5.6. Co-Authored-By: Claude Opus 5.5 --- Tests/DefaultCharsetTest.php | 32 ++++++++++++++++++++++++++++++++ docs/v4-to-v5-update.md | 8 ++++++++ src/StringHelper.php | 3 --- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 Tests/DefaultCharsetTest.php diff --git a/Tests/DefaultCharsetTest.php b/Tests/DefaultCharsetTest.php new file mode 100644 index 00000000..a1d52699 --- /dev/null +++ b/Tests/DefaultCharsetTest.php @@ -0,0 +1,32 @@ +assertFalse(class_exists(StringHelper::class, false), 'StringHelper must not be loaded yet.'); + + ini_set('default_charset', 'ISO-8859-1'); + + $this->assertTrue(class_exists(StringHelper::class)); + $this->assertSame('ISO-8859-1', ini_get('default_charset')); + } +} diff --git a/docs/v4-to-v5-update.md b/docs/v4-to-v5-update.md index e40b0a64..4af923aa 100644 --- a/docs/v4-to-v5-update.md +++ b/docs/v4-to-v5-update.md @@ -1,3 +1,11 @@ ## Updating from v4 to v5 The following changes were made to the String package between version 4 and version 5. + +### Loading `StringHelper` no longer changes `default_charset` + +In 4.x, loading `StringHelper.php` ran `@ini_set('default_charset', 'UTF-8')`, which changed a +process-wide PHP setting as a side effect. This has been removed. `UTF-8` has been PHP's default for +`default_charset` since PHP 5.6. If your `php.ini` sets a different value and your application relies +on `UTF-8`, for example for `htmlspecialchars()` or the `Content-Type` header, set it yourself in +`php.ini` or with `ini_set('default_charset', 'UTF-8')` during bootstrap. diff --git a/src/StringHelper.php b/src/StringHelper.php index 98f73e7d..3e80b11f 100644 --- a/src/StringHelper.php +++ b/src/StringHelper.php @@ -9,9 +9,6 @@ namespace Joomla\String; -// PHP mbstring and iconv local configuration -@ini_set('default_charset', 'UTF-8'); - /** * String handling class for UTF-8 data wrapping the phputf8 library. All functions assume the validity of UTF-8 strings. *