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

Clean up usages / deprecate path helpers #2155

Merged
merged 7 commits into from
Jun 19, 2020
Merged

Clean up usages / deprecate path helpers #2155

merged 7 commits into from
Jun 19, 2020

Conversation

franzliedke
Copy link
Contributor

Relates to #2055

Changes proposed in this pull request:

  • Deprecate the global path helpers, e.g. public_path()
  • Deprecate the path helpers on the Application class, e.g. Application::publicPath()

All of these are left-overs from our deeper Laravel integration. The recommended way to access these is to use the Paths class, which is injectable as a proper dependency.

All remaining changes are cleanups of places where we used the helpers ourselves - some of them quite obscure (e.g. in WritablePaths).

Reviewers should focus on:
Any downsides to removing these? I haven't yet found a case, where refactoring away from the global helpers did not result in an improvement.

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).

Required changes:

  • Related documentation PR: TODO
  • No changes to core extensions necessary

@franzliedke franzliedke requested a review from luceos May 12, 2020 13:20
Copy link
Member

@luceos luceos left a comment

Choose a reason for hiding this comment

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

I've added some comments. Especially the change to use the system tmp directory isn't really a good idea as the previous implementation tempnam would try the given directory and fallback on the system directory. This implementation now has no failsafe at all if the system tmp directory isn't writable.

src/Formatter/FormatterServiceProvider.php Show resolved Hide resolved
src/Frontend/Compiler/JsCompiler.php Show resolved Hide resolved
src/Locale/LocaleServiceProvider.php Show resolved Hide resolved
src/Queue/QueueServiceProvider.php Show resolved Hide resolved
Less I/O, and one less place where we access the global path helpers.
This was probably taken straight from Laravel. There is no equivalent
concept in Flarum, so this should be safe to remove.
Developers using these helpers can inject the `Paths` class instead.
a) The comparison was already outdated, as a different path was passed.
b) We're trying to get rid of these global helpers.
@askvortsov1
Copy link
Member

Looks good to merge IMO

@askvortsov1 askvortsov1 merged commit 88366fe into master Jun 19, 2020
@askvortsov1 askvortsov1 deleted the fl/2055-paths branch June 19, 2020 20:16
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.

4 participants