Skip to content

Optimize PHP INI defaults for embedded environment#1

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1776300649-optimize-ini-defaults
Open

Optimize PHP INI defaults for embedded environment#1
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1776300649-optimize-ini-defaults

Conversation

@devin-ai-integration
Copy link
Copy Markdown

Summary

Two changes to the embeded_ini_defaults function in embeder.cpp:

  1. Replace deprecated iconv.internal_encoding with default_charset
    iconv.internal_encoding has been deprecated since PHP 5.6 and triggers deprecation notices on PHP 8.x. The modern replacement is default_charset, which serves as the encoding default for iconv, mbstring, htmlspecialchars, and htmlentities. Value remains UTF-8.

  2. Change memory_limit from 3072M to -1 (unlimited)
    For an embedded SAPI there is no multi-tenant server environment where a per-request memory limit protects against resource exhaustion. -1 lets the OS enforce actual memory limits instead of an arbitrary 3GB ceiling.

The memory_limit and zlib.output_compression entries were reordered as a side effect; no other settings were modified.

Review & Testing Checklist for Human

  • Verify memory_limit = -1 is acceptable for your use case. If the embedded PHP environment ever runs untrusted or poorly-written scripts, removing the memory ceiling means a runaway script could consume all system memory until the OS kills the process. If a safety net is desired, consider a higher-but-finite value instead.
  • Confirm broadening from iconv.internal_encoding to default_charset is desired. default_charset has a wider scope—it also affects htmlspecialchars, htmlentities, and mbstring, not just iconv. In practice PHP 8.x already defaults default_charset to UTF-8, so the net effect should be zero, but verify no downstream code relies on default_charset being unset by the embedder.
  • Build and smoke-test on Windows with Visual Studio — this project cannot be compiled on Linux, so no build verification was performed.

Notes

  • zlib.output_compression = 0 was kept even though it is redundant (already the PHP default and irrelevant for embed SAPI which doesn't serve HTTP). Removing it is optional cleanup.
  • com.allow_dcom = 1 was reviewed but left as-is; note that it enables remote/distributed COM object instantiation, which has security implications if not needed.
  • phar.readonly = 0 was reviewed but left as-is; PHP docs recommend keeping it enabled on production machines.

Link to Devin session: https://app.devin.ai/sessions/5cc20d5ba3324bb3ba32c56d76986af7
Requested by: @ZmotriN

- Replace deprecated iconv.internal_encoding with default_charset (deprecated since PHP 5.6)
- Change memory_limit from 3072M to -1 (unlimited, appropriate for embed SAPI)

Co-Authored-By: Maxime Larrivée-Roy <maxime@diametrick.com>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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