Skip to content

Shopping list counts a recipe twice when three or more menus reference each other in a ring #810

Done

Description

@LeMyst

On the web shopping list, menus that reference each other in a ring of three or more count a recipe twice.

To reproduce, with Rice.cook, Beans.cook and Corn.cook (100 g each):

A.menu:  - @./Rice{}  and  - @./B.menu{}
B.menu:  - @./Beans{} and  - @./C.menu{}
C.menu:  - @./Corn{}  and  - @./A.menu{}

Add A.menu to the shopping list and open it: rice shows 200 g, beans and corn 100 g. cook shopping-list A.menu gives 100 g of each, with a warning naming the cycle. A ring of two (A ↔ B) is counted correctly.

Why: add_menu stores A's meals as entries of their own, B among them, with the references B follows (Beans, C.menu). The page then expands each entry on its own. add_menu drops a reference of B straight back to A (the two-menu case, from #609), but here B reaches A through C. B's expansion goes on into A, whose recipes are already on the list, and core's cycle check only stops when the chain comes back to B. Dropping C.menu from B's entry instead would lose the corn.

Since menus could be meals of each other, d99192b (#609).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions