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 post policy for PHP 8 #3145

Merged
merged 3 commits into from
Nov 1, 2021

Conversation

clarkwinkelmann
Copy link
Member

@clarkwinkelmann clarkwinkelmann commented Nov 1, 2021

Fixes #3144

Changes proposed in this pull request:
Add unit tests and fix post policy for PHP 8

Reviewers should focus on:
I'm really not sure if that's the best way to built the tests, but it does cover the original issue.

Would this best be covered by a test of the edit post API endpoint directly instead of testing just the gate?

Should I namespace the test differently?

Should I use more test methods instead of grouping the time tests?

Screenshot

Necessity

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

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

@clarkwinkelmann
Copy link
Member Author

I guess I could make the tests a tiny bit faster by re-using the models instead of calling findOrFail() each time. In particular the same user which is retrieved 4 times per test without any real need. I could also do the same for the posts but there's less gain there with 2 reuse per post. That's still a lot less DB requests. What do you think?

Copy link
Sponsor Member

@askvortsov1 askvortsov1 left a comment

Choose a reason for hiding this comment

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

LGTM! I think I would prefer variables referring to the model instances. There is a small performance improvement, but I think it'll also make the code a bit more readable.

@askvortsov1 askvortsov1 merged commit 8a69c89 into flarum:master Nov 1, 2021
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.

Edit post "until reply" policy broken on PHP8.0
3 participants