Skip to content

Fix shared hosting tmp folder issue#4446

Merged
ildyria merged 1 commit into
masterfrom
fix-tmp-dir
Jun 22, 2026
Merged

Fix shared hosting tmp folder issue#4446
ildyria merged 1 commit into
masterfrom
fix-tmp-dir

Conversation

@ildyria

@ildyria ildyria commented Jun 22, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added configurable temporary directory option (USE_SYSTEM_TEMP_DIR) to support shared hosting environments where system temp directories are inaccessible.
    • Falls back to local storage path when system temp is unavailable.
  • Bug Fixes

    • Improved diagnostic messages to reference the correct active temporary directory path.

@ildyria ildyria requested a review from a team as a code owner June 22, 2026 10:28
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Introduces a USE_SYSTEM_TEMP_DIR environment variable and corresponding features.use-system-temp-dir config flag. A new Helpers::getTmpDir() method reads this flag to return either sys_get_temp_dir() or storage/tmp/uploads_parts (creating the directory if needed). All existing sys_get_temp_dir() call sites are replaced with this helper, and diagnostics and default permission config are updated accordingly.

Changes

Configurable Temp Directory

Layer / File(s) Summary
Feature flag and env configuration
config/features.php, .env.example
Adds use-system-temp-dir config key backed by USE_SYSTEM_TEMP_DIR env var (defaults to true) with comments describing the shared-hosting use case and the storage/tmp/uploads_parts fallback.
Helpers::getTmpDir() implementation and facade
app/Assets/Helpers.php, app/Facades/Helpers.php
Adds getTmpDir(): string which reads the feature flag and returns either sys_get_temp_dir() or storage_path('tmp/uploads_parts'), creating the storage path recursively if absent. Imports Safe\mkdir and adds the @method docblock entry to the facade.
Call sites updated to use Helpers::getTmpDir()
app/Image/Files/TemporaryLocalFile.php, app/Image/Handlers/ImagickHandler.php
Replaces sys_get_temp_dir() with Helpers::getTmpDir() in getFileBasePath() and loadPdf(), adding the necessary use App\Facades\Helpers imports.
Diagnostics check and default permission config
app/Actions/Diagnostics/Pipes/Checks/IniSettingsCheck.php, app/Actions/InstallUpdate/DefaultConfig.php
Updates IniSettingsCheck to resolve the temp path through Helpers::getTmpDir() and rewrites error messages to reference the resolved path and USE_SYSTEM_TEMP_DIR=false. Adds a conditional permission rule entry for storage/tmp/uploads_parts/ in DefaultConfig when the flag is disabled.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hop, hop! No more temp-dir despair,
A flag now chooses which path to share.
sys_get_temp_dir() steps aside,
With storage/tmp as the alternate ride.
The rabbit checks permissions with care —
Shared hosting friends, your uploads are there! 🌟

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8462ec92-e96e-4a58-af31-67ec67e07a69

📥 Commits

Reviewing files that changed from the base of the PR and between 41c3cef and 0a54ad5.

📒 Files selected for processing (8)
  • .env.example
  • app/Actions/Diagnostics/Pipes/Checks/IniSettingsCheck.php
  • app/Actions/InstallUpdate/DefaultConfig.php
  • app/Assets/Helpers.php
  • app/Facades/Helpers.php
  • app/Image/Files/TemporaryLocalFile.php
  • app/Image/Handlers/ImagickHandler.php
  • config/features.php

Comment thread app/Assets/Helpers.php
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.33333% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.43%. Comparing base (7d55399) to head (0a54ad5).
⚠️ Report is 1 commits behind head on master.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ildyria ildyria merged commit 6d96e3e into master Jun 22, 2026
48 checks passed
@ildyria ildyria deleted the fix-tmp-dir branch June 22, 2026 12:21
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