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

Cannot create new (usable) userclasses within extensions #1549

Closed
Mjokfox opened this issue Mar 6, 2025 · 3 comments
Closed

Cannot create new (usable) userclasses within extensions #1549

Mjokfox opened this issue Mar 6, 2025 · 3 comments

Comments

@Mjokfox
Copy link
Contributor

Mjokfox commented Mar 6, 2025

Server Software

  • Shimmie version: 119240c
  • Database: postgres
  • Web server: nginx

What steps trigger this bug
Inside a new and enabled extension, add the function onInitExt like normal

public function onInitExt(InitExtEvent $event): void
{
    new UserClass("test", "base", []);
}

What did you expect to happen?
A new userclass is created, which can be used, in for example the "change class" dropdown on a user's page, which was the case in the latest merge i did from d325fa7

What actually happened?
the new class does not show up, and users with the class gotten beforehand now error out when loading their page since the userclass does not exist.

I have tried setting the priority of the extension higher and lower than 50, which did not change the outcome.

Or is there some other way to implement custom userclasses without having to rely on user-classes.conf.php for extensions?

@shish
Copy link
Owner

shish commented Mar 6, 2025

I am right now in the middle of reworking user classes to be stored in the database where they can be edited in a point-and-click kind of way, deprecating user-classes.conf.php (see #1149 ) - but that is still a couple of weeks away from being ready, and things are going to be a bit messy in the meantime.

Adding new user classes via extension isn't something I had ever imagined, I'm surprised that it worked at all 😅 But I will have a quick experiment and see if I can make it work again, at least temporarily (until the migration to the database is complete)

@shish
Copy link
Owner

shish commented Mar 6, 2025

This appears to be working for me 👀 (Tested by copy-pasting your onInitExt snippet into the middle of ext/comment/main.php which I happened to have open at the time)

Thinking about other recent changes which might affect this -- does your custom extension have const KEY = "<extension_id>"; defined in the main class? Extensions are now enabled/disabled by KEY (rather than by a mixture of sometimes-KEY, sometimes class-name, sometimes folder-name), so without a KEY the extension will be skipped (now that I think about it, I wonder if we can detect and warn about that...)

(FYI I'm keeping a list of major changes in https://github.com/shish/shimmie2/wiki/Upgrade#upcoming-breaking-changes-in-212 )

@Mjokfox
Copy link
Contributor Author

Mjokfox commented Mar 6, 2025

Oh you're right, i've missed that change apparently. Now it seems to work again, thanks!
I'll keep track of that major changes link, besides manually checking out the changes.

@Mjokfox Mjokfox closed this as completed Mar 6, 2025
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

No branches or pull requests

2 participants