Allow a server-wide default compile_dir and cache_dir via php.ini
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start in src/Smarty.php and review how $compile_dir and $cache_dir receive their defaults and how setCompileDir()/setCacheDir() override them. Compare the attached Smarty 3, 4, and 5 patches, then run the full test suite with and without the proposed php.ini settings. Done means configured roots work, root_strip handles the described paths, and application or subclass values and unchanged defaults still win.
Written by the indexing model from the issue text.
Description
$compile_dir and $cache_dir default to ./templates_c/ and ./cache/, which on most servers puts web-writable PHP inside the document root, even though the docs advise against it. An administrator can't change that default server-wide: each application has to call setCompileDir()/setCacheDir() (#294).
Proposal: optional php.ini settings, read with get_cfg_var():
smarty.compile_root = /var/cache/smarty_compile
smarty.cache_root = /var/cache/smarty_cache
smarty.root_strip = /var/www
When the application hasn't set a directory itself, the default becomes <root>/<cwd minus root_strip>/, so /var/www/example.com/app compiles to /var/cache/smarty_compile/example.com/app/. A cwd outside root_strip keeps the stock default; without root_strip the full path is mirrored (covers ~/public_html). No settings: nothing changes. An application's or subclass's own value always wins. Without these ini settings, nothing changes.
About 50 lines in src/Smarty.php; the full test suite passes with and without the settings. patches attached;
smarty3-compile-cache-root-default.patch
smarty4-compile-cache-root-default.patch
smarty5-compile-cache-root-default.patch
- Dominant language
- PHP
- Stars
- 2.3k
- Forks
- 705
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from smarty-php/smarty
-
Difficulty 1/5 Under an hour Newbie friendliness 79/100
smarty-php/smarty#1220 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
smarty-php/smarty#1216 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
smarty-php/smarty#1215 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 20/100
smarty-php/smarty#1218 · 4 comments · 1 reaction ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
smarty-php/smarty#1213 · 1 comment · 1 reaction ·
All issues in smarty-php/smarty
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
opnsense/core#11171 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getgrav/grav-plugin-form#664 ·
-
claude
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sprain/sprainocchio#26 ·
-
sync-en
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
sync-en
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day