Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an automated hotfix for a Filament 2 → 3 compatibility issue by patching InteractsWithForms::getFormStatePath() to be public, and wires that patch into Composer workflows with supporting documentation. It also updates composer.lock to newer dependency versions and normalizes .patch file line endings.
Changes:
- Adds a vendor patch (
patches/filament-forms-access-level.patch) and a PHP script (patches/apply-patches.php) to forcegetFormStatePath()to bepublic. - Hooks the patch application script into Composer lifecycle scripts and configures
.gitattributesandpatches.lock.jsonto support patching. - Bumps a large set of dependencies in
composer.lock(Filament, Livewire, Laravel and many others) without changingcomposer.jsonconstraints.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
patches/filament-forms-access-level.patch |
Defines the concrete code diff to change getFormStatePath() visibility from protected to public in Filament Forms. |
patches/apply-patches.php |
Implements the runtime patching logic, checking and editing the Filament vendor file after Composer operations. |
patches.lock.json |
Declares metadata for the Filament patch (for use with cweagans/composer-patches), though the plugin is not yet wired into this project. |
docs/filament-compatibility.md |
Documents the Filament 2 → 3 visibility error, the patching approach, and how to verify that the patch has been applied. |
composer.json |
Wires patches/apply-patches.php into post-autoload-dump, post-install-cmd, and post-update-cmd, and allows cweagans/composer-patches as a Composer plugin. |
.gitattributes |
Forces LF line endings for *.patch files to keep patches portable across platforms. |
composer.lock |
Updates many dependencies (Filament, Laravel, Symfony, Livewire, etc.) to newer versions matching existing version constraints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #### 3. `composer.json` | ||
| Kami memodifikasi bagian `scripts` untuk menjalankan `patches/apply-patches.php`. | ||
| - **Perubahan:** Menambahkan perintah `@php patches/apply-patches.php` pada event: | ||
| - `post-autoload-dump` | ||
| - `post-install-cmd` | ||
| - `post-update-cmd` | ||
| - **Tujuan:** Menjamin patch otomatis diterapkan setiap kali dependensi diperbarui atau autoloader di-generate ulang. | ||
|
|
||
| #### 4. `patches.lock.json` | ||
| File ini dihasilkan oleh plugin `cweagans/composer-patches`. | ||
| - **Fungsi:** Menyimpan *state* patch yang diterapkan, termasuk hash/checksum, untuk memastikan integritas dan idempotensi patch jika menggunakan plugin composer patch standar. |
There was a problem hiding this comment.
This section documents patches.lock.json as being generated and enforced by cweagans/composer-patches, and describes the PHP script as a fallback, but in the current project configuration the plugin is not installed or configured at all, while patches/apply-patches.php is wired into Composer scripts and is effectively the primary mechanism. To avoid confusion for maintainers, please either (a) actually wire up cweagans/composer-patches in composer.json, or (b) adjust the documentation to explain that the PHP script is the canonical patch mechanism and patches.lock.json is currently informational only.
| // Apply patch: change protected to public for getFormStatePath | ||
| $original = 'protected function getFormStatePath(): ?string'; | ||
| $patched = 'public function getFormStatePath(): ?string'; | ||
|
|
||
| if (strpos($content, $original) === false) { | ||
| echo "⚠ Could not find method to patch\n"; | ||
| exit(1); |
There was a problem hiding this comment.
When the upstream Filament package eventually ships a version where this method signature is changed or already public, this strpos($content, $original) === false branch will cause every composer install / composer update to exit with status 1, even though the patch is no longer needed. To make the project resilient to upstream fixes, consider treating the "method not found" case as a no-op with a warning (exit code 0) rather than a hard error, so that dependency upgrades are not blocked when the patch becomes obsolete.
| "allow-plugins": { | ||
| "pestphp/pest-plugin": true | ||
| "pestphp/pest-plugin": true, | ||
| "cweagans/composer-patches": true | ||
| } |
There was a problem hiding this comment.
The PR description and this config suggest that cweagans/composer-patches is being used to manage the Filament patch, but the package is not present in require-dev nor in composer.lock, and there is no extra.patches configuration. As a result, the plugin will never actually run for this project, and only the custom patches/apply-patches.php script will apply the fix. To align behavior with the documentation and PR description, either add and configure cweagans/composer-patches in composer.json (including require-dev and extra.patches) or update the docs/description to state clearly that the PHP script is the sole mechanism applying the patch.
Deskripsi
patches\filament-forms-access-level.patchcweagans\composer-patches ke require-devbaca patch inidocs/filament-compatibility.mdscripts->post-autoload-dumpsection di composer.json📌 Kenapa perlu pakai patch dengan cweagans/composer-patches
Saat kamu upgrade dari Filament v2 ke Filament v3, ada perubahan API internal yang belum sepenuhnya kompatibel. Salah satunya adalah method getFormStatePath() di trait InteractsWithForms yang awalnya protected, tetapi di kelas lain (mis. Filament\Resources\Pages\ViewRecord) membutuhkan visibility yang lebih luas (public).
PHP memiliki aturan ketat tentang method visibility inheritance:
Dalam kasus ini errornya:
Hal ini terjadi di dalam paket Filament itu sendiri (vendor), bukan di kode aplikasi kamu. Sementara:
👉 Karena itu solusi sementara tapi dapat diulang secara otomatis adalah dengan menggunakan package cweagans/composer-patches untuk mem‐patch file vendor setiap kali Composer melakukan install/update.
Plugin ini memungkinkan kamu untuk:
✅ menetapkan patch yang otomatis diaplikasikan pada vendor
✅ version control patch tersebut (disimpan di repositori kamu)
✅ tidak perlu edit vendor/ secara manual setiap kali install/update
Dengan begitu patch bisa tetap ter‐apply sampai upstream Filament benar-benar memperbaiki bug ini.
Ini adalah praktik standard untuk hotfix sementara sebelum perbaikan resmi dirilis.
📌 Dokumentasi error kompatibilitas Filament 2 → Filament 3
Ada issue resmi yang dibuat oleh pengguna Filament sendiri di GitHub yang menjelaskan error ini muncul saat upgrade dari Filament v2 ke v3, dengan pesan yang sama seperti yang kamu alami:
👉 Issue #13931 – Upgrade filament v2 to v3 didnt work
Link:
https://github.com/filamentphp/filament/issues/13931
Isi utamanya:
👉 Ini menunjukkan bahwa masalah ini memang kompatibilitas terkait perubahan internal Filament antara v2 dan v3
Untuk isu:
Cara replikasi
composer installpatch akan otomatis diterapkan tanpa perlu manual edit. Tidak ada error lagi di Filament Forms.