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

3.8.3 ViteBundler incompatibility with Laravel 9 #1223

Closed
vikasiwp opened this issue May 17, 2024 · 3 comments
Closed

3.8.3 ViteBundler incompatibility with Laravel 9 #1223

vikasiwp opened this issue May 17, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@vikasiwp
Copy link

Bug description

Started getting 500 error when updated packages to 3.8.3

[Fri May 17 12:09:49.839792 2024] [proxy_fcgi:error] [pid 540374:tid 140198747334400] [client 143.244.87.125:0] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught ErrorException: Undefined property: Stancl\Tenancy\Vite::$assetPathResolver in /path/to/your/project/vendor/stancl/tenancy/src/Vite.php:18\nStack trace:\n#0 /path/to/your/project/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(270): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()\n#1 /path/to/your/project/vendor/stancl/tenancy/src/Vite.php(18): Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure}()\n#2 /path/to/your/project/vendor/laravel/framework/src/Illuminate/Foundation/Vite.php(283): Stancl\Tenancy\Vite->assetPath()\n#3 /path/to/your/project/storage/framework/views/0d81735404e0982d099e7a1fe299815bfe173fc9.php(17): Illuminate\Foundation\Vite->__invoke()\n#4 /path/to/your/project/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(270): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()\n#1 /path/to/your/project/vendor/stancl/tenancy/src/Vite.php(18): Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure}()\n#2 /path/to/your/project/vendor/laravel/framework/src/Illuminate/Foundation/Vite.php(283): Stancl\Tenancy\Vite->assetPath()\n#3 /path/to/your/project/storage/framework/views/0d81735404e0982d099e7a1fe299815bfe173fc9.php(17): Illuminate\Foundation\Vite->__invoke()\n#4 /path/to/your/project/vendor/laravel/framework/src/Illuminate/Foundation/Vite.php(283): Stancl\Tenancy\Vite->assetPath()\n#3 /path/to/your/project/storage/framework/views/0d81735404e0982d099e7a1fe299815bfe173fc9.php(17): Illuminate\Foundation\Vite->__invoke()\n#4 /path/to/your/project/...'

Steps to reproduce

Unknown at the moment, we use multi-tenancy and just upgraded the composer package without any code changes.

Expected behavior

No error.

Laravel version

9

stancl/tenancy version

3.8.3

@vikasiwp vikasiwp added the bug Something isn't working label May 17, 2024
@stancl
Copy link
Member

stancl commented May 17, 2024

Can you test the following patch?

diff --git a/vendor/stancl/tenancy/src/Vite.php b/vendor/stancl/tenancy/src/Vite.php
index 1464e3a3..91ab9aad 100644
--- a/vendor/stancl/tenancy/src/Vite.php
+++ b/vendor/stancl/tenancy/src/Vite.php
@@ -15,6 +15,9 @@ class Vite extends BaseVite // todo move to a different directory in v4
      */
     protected function assetPath($path, $secure = null)
     {
-        return $this->assetPathResolver ? ($this->assetPathResolver)($path, $secure) : global_asset($path);
+        // In Laravel 9, the property doesn't exist.
+        return (isset($this->assetPathResolver) && $this->assetPathResolver)
+            ? ($this->assetPathResolver)($path, $secure)
+            : global_asset($path);
     }
 }

1221_fix.patch

@stancl stancl changed the title Major production issue due to 3.8.3 3.8.3 ViteBundler incompatibility with Laravel 9 May 17, 2024
@lynexer
Copy link

lynexer commented May 22, 2024

The above patch does fix the issue within Laravel 9.

@stancl stancl closed this as completed in 885179b May 22, 2024
@stancl
Copy link
Member

stancl commented May 22, 2024

Thanks for the confirmation, tagging a release now.

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
None yet
Development

No branches or pull requests

3 participants