Skip to content

Use atomic writes when creating inline Blade component views#58815

Merged
taylorotwell merged 2 commits intolaravel:12.xfrom
cyppe:fix/atomic-inline-blade-view-writes
Feb 14, 2026
Merged

Use atomic writes when creating inline Blade component views#58815
taylorotwell merged 2 commits intolaravel:12.xfrom
cyppe:fix/atomic-inline-blade-view-writes

Conversation

@cyppe
Copy link
Contributor

@cyppe cyppe commented Feb 14, 2026

Why

Inline Blade component views (created from strings) are written to config('view.compiled') by Illuminate\View\Component::createBladeViewFromString().

Today this uses file_put_contents() directly, which can temporarily truncate the target file to 0 bytes while concurrent requests attempt to read/compile it (notably under highly concurrent runtimes like FrankenPHP). This can surface as intermittent empty renders / missing root tags in downstream consumers.

What

  • Write inline *.blade.php files using Illuminate\Filesystem\Filesystem::replace() (atomic temp file + rename).
  • Re-write the file if it exists but is 0 bytes (repairs prior truncated cache artifacts).
  • Keep directory creation logic consistent with existing code.

Tests

  • php vendor/bin/phpunit tests/View/ComponentTest.php

@taylorotwell taylorotwell merged commit 058b096 into laravel:12.x Feb 14, 2026
45 of 70 checks passed
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.

2 participants

Comments