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

Uploading a workflow with categories that do not exist throws errors. #194

Closed
NinaHerrmann opened this issue Feb 20, 2024 · 2 comments · Fixed by #196
Closed

Uploading a workflow with categories that do not exist throws errors. #194

NinaHerrmann opened this issue Feb 20, 2024 · 2 comments · Fixed by #196
Assignees
Labels

Comments

@NinaHerrmann
Copy link
Contributor

When downloading a workflow (wf) that uses a category trigger the upload can not handle unknown categories.
The .XML file uses the id of the categories to identify the categories to be used. When this ID is not allocated in the system e.g.

$children = $categoryobjects[$category]->get_all_children_ids();

throws Call to a member function get_all_children_ids() on bool .

To the best of my knowledge, the most reasonable behavior would be to either
a) delete the category trigger completely during the upload process.
b) replace the category with some random category
and provide a warning to the user.

I am not completely happy with both options but I guess implementing a category selection option during the upload process is overkill.

@lucaboesch
Copy link
Collaborator

Or could we just check whether $categoryobjects[$category] isn't boolean at the beginning of the
foreach ($categories as $category) {
loop?

@lucaboesch
Copy link
Collaborator

The proposed fix contains

            array_push($allcategories, $category);
            if (!isset($categoryobjects[$category]) || !$categoryobjects[$category]) {
                continue;
            }
            $children = $categoryobjects[$category]->get_all_children_ids();
            $allcategories = array_merge($allcategories, $children);

Sorry for the noise.
All good.

I think this issue can also appear if you delete a category (that has already been emptied) whilst the process of backup and delete in a category trigger is still ongoing. Then, at a certain point, this hits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants