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

fix: prevent multiple evaluations when getStateUsing is called #14852 #15246

Conversation

borjajimnz
Copy link
Contributor

Description

As mentioned in #14852, this issue was causing multiple evaluations. This fix ensures that only the final evaluation is performed, which I believe is the correct approach.

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

@mc-fu
Copy link

mc-fu commented Jan 6, 2025

this breaks the use of fn and function within getStateUsing!

@borjajimnz
Copy link
Contributor Author

this breaks the use of fn and function within getStateUsing!

Have you tested it @mc-fu ? is not breaking nothing for me.

https://www.youtube.com/watch?v=VzFf0Vas0j8

@@ -76,7 +76,7 @@ public function getState(): mixed
}

$state = ($this->getStateUsing !== null) ?
$this->evaluate($this->getStateUsing) :
$this->getStateUsing :
$this->getStateFromRecord();

if (is_string($state) && ($separator = $this->getSeparator())) {
Copy link
Member

Choose a reason for hiding this comment

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

The breaking comment is correct, if the function returns a string that needs separating here or a blank value it would break

@danharrin danharrin added the bug Something isn't working label Jan 6, 2025
@danharrin danharrin added this to the v3 milestone Jan 6, 2025
@mc-fu
Copy link

mc-fu commented Jan 6, 2025

Yeah, sorry, I needed to be more precise:

When using "->money('EUR')" option on this as well, I get the following error with your fix:

Too few arguments to function App\Filament\Resources\StlResource::App\Filament\Resources\{closure}(), 0 passed in /var/www/testdev/vendor/laravel/framework/src/Illuminate/Collections/helpers.php on line 236 and exactly 1 expected

@borjajimnz
Copy link
Contributor Author

This is more complex than I initially thought; I'll need some time to process it. I'll reopen the PR if I find a way to handle it.

@borjajimnz borjajimnz closed this Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants