Skip to content

Call to a member function getStorage() on null #1256

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

Closed
hollaweb opened this issue Mar 3, 2025 · 8 comments
Closed

Call to a member function getStorage() on null #1256

hollaweb opened this issue Mar 3, 2025 · 8 comments
Labels
done Issue is fixed. Will be closed in 7 days.

Comments

@hollaweb
Copy link

hollaweb commented Mar 3, 2025

Bug after upgrade to Laravel 12 and filemanager 2.10

Specifications

  • Operating system : Win 11
  • Laravel version : 12.0.1
  • Package version : 2.10
  • Screenshots of browser console :

Image

@vaneetjoshi
Copy link

The issue arises because the LfmPath class's constructor allows a null default for the Lfm dependency. This can leave the helper property unset, leading to the Call to a member function getStorage() on null error.

To fix this, update the constructor in the UniSharp\LaravelFilemanager package as follows:

Original Code
public function __construct(Lfm $lfm = null) { $this->helper = $lfm; }

Updated Code
public function __construct(Lfm $lfm) { $this->helper = $lfm; }

This enforces dependency injection of the Lfm object, ensuring the helper property is always set.

Important Note
If you plan to modify the package, you should fork the repository first to keep track of your changes. Directly editing files in the vendor directory is not recommended, as your changes will be overwritten during future updates.

After making this change, remember to clear the application cache and regenerate the autoload files:

This should resolve the issue.

@hollaweb
Copy link
Author

hollaweb commented Mar 3, 2025

thanks you, the problem has been solved. But I will wait for the next update to avoid any unexpected errors

@Raza9798
Copy link

Raza9798 commented Mar 7, 2025

Image

after do the update on package file it looks like above, is this how it should render? @vaneetjoshi @hollaweb

@hollaweb
Copy link
Author

hollaweb commented Mar 8, 2025

mine is the same, but when put into real application it works fine @Raza9798

@Raza9798
Copy link

Okay great.

@jonnott
Copy link
Contributor

jonnott commented Mar 11, 2025

@hollaweb Made a PR #1257

@streamtw

@streamtw
Copy link
Member

Just released a new version that contains the fix by @jonnott . Please upgrade to v2.10.1.

@jonnott
Copy link
Contributor

jonnott commented Mar 11, 2025

@hollaweb Can you close the issue once you've upgraded and are happy it's resolved? Thanks (I don't have permissions)

@streamtw streamtw added the done Issue is fixed. Will be closed in 7 days. label Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done Issue is fixed. Will be closed in 7 days.
Projects
None yet
Development

No branches or pull requests

5 participants