Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] PHP Deprecated: Optional parameter HasForm #5458

Closed
adriallongarriu opened this issue Feb 28, 2024 · 2 comments
Closed

[Bug] PHP Deprecated: Optional parameter HasForm #5458

adriallongarriu opened this issue Feb 28, 2024 · 2 comments
Labels

Comments

@adriallongarriu
Copy link
Contributor

Bug report

What happened

I upload a new project to a new server with 8.2.11
On acces the admin created a error.log with the error:

PHP Deprecated:  Optional parameter $id declared before required parameter $formLogic is implicitly treated as a required parameter in .../vendor/backpack/crud/src/app/Http/Controllers/Operations/Concerns/HasForm.php on line 104

Line 104

public function formAction(?int $id = null, callable $formLogic)
{
//
}

What I've already tried to fix it

I followed https://php.watch/versions/8.0/deprecate-required-param-after-optional
image

The error was reptining multiple times and for not create a larage log flies i temporary i changed vendor to:

public function formAction(?int $id, callable $formLogic)
{
//
}

Is it a bug in the latest version of Backpack?

Yes

Backpack, Laravel, PHP, DB version

LARAVEL VERSION:

10.43.0.0

BACKPACK PACKAGE VERSIONS:

backpack/basset: 1.2.2
backpack/crud: 6.6.2
backpack/generators: v4.0.3
backpack/permissionmanager: 7.1.1
backpack/pro: 2.1.2
backpack/settings: 3.1.0
backpack/theme-tabler: 1.2.0

@jcastroa87
Copy link
Member

Hello @adriallongarriu, thanks for reporting this. I will ask @pxpm to check on this situation.

Cheers.

@pxpm
Copy link
Contributor

pxpm commented Mar 1, 2024

Hey @adriallongarriu thanks for the report.

Indeed we need to make a breaking change there to change the order of those parameters.

I've created #5459 to address that.

In preparation for that BC I've also created Laravel-Backpack/Generators#204

The new generated FormOperations will now be using named parameters, so it will not be a breaking change if you generate your forms after I merge and tag that PR in a few moments.
If you want to prepare yourself and avoid having a BC in forms that you already created, you can also use the named parameters in $this->formAction().

Thanks in advance for the report 🙏

@pxpm pxpm closed this as completed Mar 1, 2024
@github-project-automation github-project-automation bot moved this to Done in This week Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

3 participants