Skip to content

Perbaikan compser#52

Merged
apidong merged 15 commits intodevelopmentfrom
perbaikan-compser
Jan 22, 2026
Merged

Perbaikan compser#52
apidong merged 15 commits intodevelopmentfrom
perbaikan-compser

Conversation

@ujgsp
Copy link

@ujgsp ujgsp commented Jan 6, 2026

Deskripsi

  • Support perbaikan composer, untuk mengatasi masalah bug setelah update versi filament 2 ke 3
  • Membuat file patch: patches\filament-forms-access-level.patch
  • Menambah package cweagans\composer-patches ke require-dev baca patch ini
  • Dokumentasi disini docs/filament-compatibility.md
patches\apply-patches.php
patches\filament-forms-access-level.patch
  • Menambah konfigurasi patches scripts -> post-autoload-dump section di composer.json
"post-autoload-dump": [
            "@php patches/apply-patches.php",
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-install-cmd": [
            "@php patches/apply-patches.php"
        ],
  • Mengizinkan plugin di allow-plugins di composer.json
"allow-plugins": {
            "pestphp/pest-plugin": true
            "pestphp/pest-plugin": true,
            "cweagans/composer-patches": true
        }

📌 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:

Method dengan access level lebih sempit (protected) tidak boleh menurunkan method yang harusnya public.
Ini karena class lain mencoba memanggil method tersebut sebagai public, dan PHP akan me‐throw fatal error jika visibilitas >tidak cocok.

Dalam kasus ini errornya:

Access level to Filament\Forms\Concerns\InteractsWithForms::getFormStatePath() must be public …

Hal ini terjadi di dalam paket Filament itu sendiri (vendor), bukan di kode aplikasi kamu. Sementara:

  • Filament 3 belum menyediakan fix resmi untuk ini pada rilis tertentu
  • Patch upstream belum masuk di versi stable
  • Kamu tidak bisa downgrade tanpa merusak versi Filament lainnya

👉 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:

  • user mencoba upgrade Filament ke versi 3
  • muncul error:
Access level to Filament\Forms\Concerns\InteractsWithForms::getFormStatePath() must be public …
  • error ini terjadi di dalam paket Filament, bukan aplikasi user
  • pengguna tidak yakin bagaimana memperbaikinya karena letaknya di vendor
    👉 Ini menunjukkan bahwa masalah ini memang kompatibilitas terkait perubahan internal Filament antara v2 dan v3

Untuk isu:

Cara replikasi

  • jalankan perintah composer install patch akan otomatis diterapkan tanpa perlu manual edit. Tidak ada error lagi di Filament Forms.

@ujgsp ujgsp requested a review from apidong January 6, 2026 09:32
@ujgsp ujgsp removed the request for review from apidong January 7, 2026 01:24
@ujgsp ujgsp changed the title Perbaikan compser Perbaikan compser (masih dikerjakan) Jan 7, 2026
@ujgsp ujgsp changed the title Perbaikan compser (masih dikerjakan) Perbaikan compser Jan 7, 2026
@ujgsp ujgsp requested a review from apidong January 7, 2026 02:54
@apidong apidong requested a review from Copilot January 22, 2026 06:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 force getFormStatePath() to be public.
  • Hooks the patch application script into Composer lifecycle scripts and configures .gitattributes and patches.lock.json to support patching.
  • Bumps a large set of dependencies in composer.lock (Filament, Livewire, Laravel and many others) without changing composer.json constraints.

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.

Comment on lines +35 to +45
#### 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.
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +30
// 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);
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 111 to 114
"allow-plugins": {
"pestphp/pest-plugin": true
"pestphp/pest-plugin": true,
"cweagans/composer-patches": true
}
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@apidong apidong merged commit df56a6d into development Jan 22, 2026
6 checks passed
@apidong apidong mentioned this pull request Jan 22, 2026
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.

3 participants