-
-
Notifications
You must be signed in to change notification settings - Fork 834
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
Fixes model visibility #2580
Fixes model visibility #2580
Conversation
Model Visibility extender does not take into consideration missing dependencies. For instance flarum/tags adds a policy on the Flag model from flarum/flags. But because flarum/flags might as well not be installed we need to check for the existence of that model. Otherwise the exception is thrown or flarum fails to boot.
Issue: #2539 Alternate PR: flarum/tags#109 I like this one better though since it's more generic. Maybe there are other issues we need to fix this for? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have a test case extending a non-existent class?
@@ -44,7 +44,7 @@ public function __construct(string $modelClass) | |||
{ | |||
$this->modelClass = $modelClass; | |||
|
|||
if (! method_exists($modelClass, 'registerVisibilityScoper')) { | |||
if (class_exists($this->modelClass) && ! is_callable([$modelClass, 'registerVisibilityScoper'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this fail silently if the model doesn't exist? Although I suppose that would be inline with behavior of current extensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original idea behind the policy was to apply only when flags was installed. I don't think we need to log anything here.
Model Visibility extender does not take into consideration missing
dependencies. For instance flarum/tags adds a policy on the Flag model
from flarum/flags. But because flarum/flags might as well not be
installed we need to check for the existence of that model. Otherwise
the exception is thrown or flarum fails to boot.