F
Filamentβ€’13mo ago
ToonVD

Stuck on upgrade

Typed static property Filament\Resources\Pages\Page::$resource must not be accessed before initialization We get the above error. Trace does not go outside vendor code so it doesn't seem to be custom code. Any ideas?
12 Replies
toeknee
toekneeβ€’13mo ago
It will be outside vendor code, I suspect you are calling the resource or model somewhere and it's inheirted by vendor code or extended. Is this on a specific page?
ToonVD
ToonVDOPβ€’13mo ago
No, it's on post autoload command and basically everywhere. I will check. So, turns out I forgot to declare the global resource var on one of my pages. In Filament 2, this didn't cause issues, in 3 it did.
class MyPage extends Page
{
public function mount($page_id)
class MyPage extends Page
{
public function mount($page_id)
to
class MyPage extends Page
{
protected static string $resource = MyPageResource::class;

public function mount($page_id)
class MyPage extends Page
{
protected static string $resource = MyPageResource::class;

public function mount($page_id)
The error was a bit vague though. Took a bit of debugging πŸ™‚
toeknee
toekneeβ€’13mo ago
Good stuff, we will add it to the V3 upgrade docs. I suspect that's when people have created their own pages.
ToonVD
ToonVDOPβ€’13mo ago
Yes, this was a custom page, sorry for the late reply.
toeknee
toekneeβ€’13mo ago
@ToonVD can you provide the whole start of your file to the mount function?
ToonVD
ToonVDOPβ€’13mo ago
The one that fixed it? Yes, hold on
toeknee
toekneeβ€’13mo ago
Yeah please, just need to know where it was extending from etc as it's a custom page it may have been setup slightly different than anticipated
ToonVD
ToonVDOPβ€’13mo ago
<?php

namespace App\Filament\Resources\MyResource\Pages;

use App\Filament\Resources\MyResource;
use Filament\Resources\Pages\Page;

class MyPage extends Page
{
protected static string $resource = MyResource::class;

public function mount($resource_id)
{
}
}
<?php

namespace App\Filament\Resources\MyResource\Pages;

use App\Filament\Resources\MyResource;
use Filament\Resources\Pages\Page;

class MyPage extends Page
{
protected static string $resource = MyResource::class;

public function mount($resource_id)
{
}
}
toeknee
toekneeβ€’13mo ago
Thank you! So I am trying to solve the issue with that's caused this, do you have a full pre and post upgrade copy? You can send me a DM with them if you prefer. So I can see what's happening
ToonVD
ToonVDOPβ€’13mo ago
You want both the resource and the page itself? I can send a Git diff
toeknee
toekneeβ€’13mo ago
yeah before and after the upgrade, I've got a feeling the upgrade script is changing somehting between the two itterations depending on how the custom pages have been created
ToonVD
ToonVDOPβ€’13mo ago
In PM Did you manage to reproduce?
Want results from more Discord servers?
Add your server