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 use Tags extension if Flags is uninstalled, inexisting model cannot be visibility scoped #2539

Closed
clarkwinkelmann opened this issue Jan 13, 2021 · 1 comment · Fixed by #2580
Milestone

Comments

@clarkwinkelmann
Copy link
Member

Bug Report

Current Behavior
Trying to use the Tags extension while not having Flags installed causes a boot error that prevents access to the forum.

Steps to Reproduce

  1. Install fresh Flarum, or just enable any extensions including Tags
  2. composer remove flarum/approval flarum/flags (Approval must be removed as well because it requires Flags)
  3. Try to access forum. Observe boot error
Flarum encountered a boot error (Exception)
Model Flarum\Flags\Flag cannot be visibility scoped as it does not use Flarum\Database\ScopeVisibilityTrait.
thrown in /home/clark/Projects/flarum-beta15/vendor/flarum/core/src/Extend/ModelVisibility.php on line 48

Exception: Model Flarum\Flags\Flag cannot be visibility scoped as it does not use Flarum\Database\ScopeVisibilityTrait. in /home/clark/Projects/flarum-beta15/vendor/flarum/core/src/Extend/ModelVisibility.php:48
Stack trace:
#0 /home/clark/Projects/flarum-beta15/vendor/flarum/tags/extend.php(86): Flarum\Extend\ModelVisibility->__construct('Flarum\\Flags\\Fl...')
#1 /home/clark/Projects/flarum-beta15/vendor/flarum/core/src/Extension/Extension.php(307): require('/home/clark/Pro...')
#2 /home/clark/Projects/flarum-beta15/vendor/flarum/core/src/Extension/Extension.php(129): Flarum\Extension\Extension->getExtenders()
#3 /home/clark/Projects/flarum-beta15/vendor/flarum/core/src/Extension/ExtensionManager.php(334): Flarum\Extension\Extension->extend(Object(Illuminate\Container\Container))
#4 /home/clark/Projects/flarum-beta15/vendor/flarum/core/src/Extension/ExtensionServiceProvider.php(30): Flarum\Extension\ExtensionManager->extend(Object(Illuminate\Container\Container))
#5 [internal function]: Flarum\Extension\ExtensionServiceProvider->Flarum\Extension\{closure}(Object(Flarum\Foundation\Application))
#6 /home/clark/Projects/flarum-beta15/vendor/flarum/core/src/Foundation/Application.php(322): call_user_func(Object(Closure), Object(Flarum\Foundation\Application))
#7 /home/clark/Projects/flarum-beta15/vendor/flarum/core/src/Foundation/Application.php(263): Flarum\Foundation\Application->fireAppCallbacks(Array)
#8 /home/clark/Projects/flarum-beta15/vendor/flarum/core/src/Foundation/InstalledSite.php(148): Flarum\Foundation\Application->boot()
#9 /home/clark/Projects/flarum-beta15/vendor/flarum/core/src/Foundation/InstalledSite.php(81): Flarum\Foundation\InstalledSite->bootLaravel()
#10 /home/clark/Projects/flarum-beta15/vendor/flarum/core/src/Http/Server.php(56): Flarum\Foundation\InstalledSite->bootApp()
#11 /home/clark/Projects/flarum-beta15/vendor/flarum/core/src/Http/Server.php(33): Flarum\Http\Server->safelyBootAndGetHandler()
#12 /home/clark/Projects/flarum-beta15/public/index.php(26): Flarum\Http\Server->listen()
#13 {main}

Expected Behavior
Two things could be done. Either:

  • Flags needs to be a required dependency of Tags
  • The Extend\ModelVisibility extender must somehow accept and skip missing classes

If we go with the first, then removing Flags with composer simply wouldn't remove the package and not cause any error.

If we go with the second, then we expect no boot error.

Environment

  • Flarum version: beta 15

Possible Solution
See above

Additional Context
Found while running unit tests that load Tags only. But this could reasonably happen on a forum where the admin decides to completely remove Flags.

@clarkwinkelmann
Copy link
Member Author

Existing PR flarum/tags#109

@askvortsov1 askvortsov1 linked a pull request Jan 29, 2021 that will close this issue
@askvortsov1 askvortsov1 added this to the 0.1.0-beta.16 milestone Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants