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

Fixes model visibility #2580

Merged
merged 1 commit into from
Jan 29, 2021
Merged

Fixes model visibility #2580

merged 1 commit into from
Jan 29, 2021

Conversation

luceos
Copy link
Member

@luceos luceos commented Jan 28, 2021

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.

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.
@askvortsov1
Copy link
Member

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?

Copy link
Member

@askvortsov1 askvortsov1 left a 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'])) {
Copy link
Member

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.

Copy link
Member Author

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.

@askvortsov1 askvortsov1 merged commit 964f827 into master Jan 29, 2021
@askvortsov1 askvortsov1 deleted the dk/fix-model-visibility branch January 29, 2021 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot use Tags extension if Flags is uninstalled, inexisting model cannot be visibility scoped
3 participants