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

mod_base: Handle unknown categories separately in is_a filter. #3072

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mmzeeman
Copy link
Member

Description

Fix #3071

Handle the case unknown category separately. This can happen when categories are removed.

Checklist

  • documentation updated
  • tests added
  • no BC breaks

@mmzeeman mmzeeman requested a review from mworrell July 27, 2022 09:35
@@ -25,9 +25,7 @@ is_a({rsc_list, List}, Cat, Context) ->
is_a(Arg, Cat, Context) ->
case m_category:name_to_id(Cat, Context) of
{ok, CatId} -> z_list_of_ids_filter:filter(Arg, fun(Id) -> m_rsc:is_a(Id, CatId, Context) end, Context);
{error, {unknown_category, _}} -> false;
{error, _Reason} when is_integer(Arg) -> false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this when is too strict.

The check on is_list might move up and this one might just be the default.

Applying the is_a filter on a list (or list-alike thing) should perform like a filter on some category. That is why the when on is_list(Arg) is there, to return an empty list.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah... the error clauses match on the input, not on the error itself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to do this later today. I'll refactor it a bit to clarify a bit more that is_a produces different answers when there is no match depending on the input.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The {rsc_list, _} is now also a record: #rsc_list{ list = List }.

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

Successfully merging this pull request may close these issues.

Deleting categories causes admin site to become unavailable.
2 participants