Skip to content

fix(upgrade): generate valid PHP for an API resource without a model - #65

Merged
imorland merged 1 commit into
3.xfrom
im/api-resource-implements
Oct 14, 2026
Merged

imorland merged 1 commit into
3.xfrom
im/api-resource-implements

Conversation

@imorland

Copy link
Copy Markdown
Member

Fixes #51

Changes proposed in this pull request:
When the JSON:API step can't link a serializer to a model, it generates a resource on AbstractResource. That resource always got implements, even with no interfaces after it, because the template's if had no braces. The invalid PHP then crashed the next step's parser. A resource with no model also lost the comma after Endpoint\Create::make(), and the stub's index endpoint choice returned a value the template never checks.

Reviewers should focus on:

  • A resource with no model that implements the contracts still lacks the methods they require (query(), find(), …). It parses now, but needs those methods written by hand, as the upgrade guide already says.

Screenshot
N/A

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered? (N/A)
  • For core PRs, does this need to be in core, or could it be in an extension? (N/A)
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation. (The built CLI ran upgrade 2.0 to the end on the reporter's 1.x code.)
  • Frontend changes: tests are green (run yarn test in js/).
  • Frontend changes: tests have been added, or are not appropriate here.
  • Backend changes: tests are green (run composer test). (N/A)
  • Backend changes: tests have been added, or are not appropriate here. (N/A)
  • Where applicable, changes are suitable for all supported database drivers (MySQL, MariaDB, PostgreSQL, SQLite). (N/A)
  • Core developer confirmed locally this works as intended.
  • The description above is written by me and describes what this pull request actually does.

@imorland
imorland marked this pull request as ready for review October 14, 2026 15:18
@imorland
imorland merged commit d2702bc into 3.x Oct 14, 2026
2 checks passed
@imorland
imorland deleted the im/api-resource-implements branch October 14, 2026 15: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.

Error when running fl2 upgrade 2.0 on my extension

1 participant