Skip to content

[5.x] Remove the default_charset side effect of StringHelper - #86

Open
Hackwar wants to merge 2 commits into
joomla-framework:5.x-devfrom
Hackwar:5.x-remove-default-charset
Open

Hackwar wants to merge 2 commits into
joomla-framework:5.x-devfrom
Hackwar:5.x-remove-default-charset

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

When StringHelper.php is loaded, it runs @ini_set('default_charset', 'UTF-8') at file scope. That changes a process-wide PHP setting (the defaults of htmlspecialchars()/html_entity_decode() and the Content-Type charset), depending on whether some code has loaded the class yet. UTF-8 has been PHP's default since 5.6. This PR removes the side effect.

Testing Instructions

New Tests/DefaultCharsetTest.php runs in a separate process: it sets default_charset to ISO-8859-1, autoloads StringHelper, and asserts that the setting is unchanged. It fails before the change and passes after it. vendor/bin/phpunit is green, phpcs is clean, and PHPStan reports no errors locally. The PHPStan job in CI fails on 4.x-dev/5.x-dev as well, and #66 fixes that on 4.x.

Documentation Changes Required

docs/v4-to-v5-update.md: a section "Loading StringHelper no longer changes default_charset" that says what to do if an application relied on it.

When 4.x-dev is merged up, the section that #82 adds to docs/overview.md, and #72's "A note on loading this package", have to be removed on 5.x.

Depends on #84 (this branch is built on it, so its commit shows up here until #84 is merged) and on #82, which deprecates the side effect in 4.x. #82 adds a @deprecated comment above the removed line, which has to be resolved as a deletion when 4.x-dev is merged up. Related to #85, which also appends a section to docs/v4-to-v5-update.md, so expect a small conflict there.

🤖 Generated with Claude Code

Hackwar and others added 2 commits November 13, 2026 01:25
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant