Cannot use same category name twice
https://github.com/modmore/Gitify/wiki/9.-Example-.gitify-files
There seems to be a problem with the primary key 'category'. This stores the name of the category, but when you have nested categories bearing the same name, only the last one is being picked up by Gitify.
It's not defined as primary in modx.mysql.schema.xml, so I think you might as well use 'id' as primary key here.. Is that correct?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
In addition: the categories are also being referenced by name in the .yaml file of every element..
I didn't know you could have multiple categories with the same name? Op 27 apr. 2015 9:45 AM schreef "Hugo Peek" [email protected]:
In addition: the categories are also being referenced by name in the .yaml file of every element..
— Reply to this email directly or view it on GitHub https://github.com/modmore/Gitify/issues/84#issuecomment-96542370.
I'm digging this one up and renaming it, because it keeps coming back as an issue in my projects..
The problem is that identical category names in different parent folders are not recognised as separate categories. (Yep, apparently that's possible @Mark-H.. ;)) So say you have the following category structure:
Component A > Settings Component B > Settings Component C > Subcategory > Settings
Elements will now be placed in 1 of these Settings folders, also if you set ID as primary key in the .gitify file:
categories:
class: modCategory
primary: id
truncate_on_force:
- modCategoryClosure
This is because they are referenced by name in the .yaml files, without any further reference to their parent category:
id: 15
source: 12
name: breadcrumbs
description: ''
category: Navigation
properties: 'a:0:{}'
static: 1
static_file: 01-molecules/navigation/breadcrumbs.tpl
For bigger projects, this turns into a problem because you can't keep track of whether a category name is unique anymore or not. Besides, sometimes it's good to have a bit of consistency for end users too, in that they have the same Settings tab in their TV's for example for different components.
It would be great if this "feature" could be implemented. We are also running into the same problem on larger projects
IMHO it is not a missing feature, but a bug. Yes, it is possible to have multiple categories with the same name. And even if you don't use that personally for your project, the installed extras may use same category names for subcategories. Workaround at least for your own categories until this is fixed: implement some kind of namespace prefixing for subcategories:
Component A > A_Settings
Component B > B_Settings
Component C > Subcategory > C__Settings
But this is ugly and contradicts consistency work...
Unfortunately thats still an issue and its still a bug. If you have two different categories with the same name, gitify will sort every element into the first category (lowest id) with that name on build - this is changing then the id of the category in the elements table row. Thus changing the state you extracted.
@Mark-H could you please change the label of this issue to ~Bug so its not dangling around here as a simple feature request any more?
I found the following code in ExtractCommand lines 479+ which introduces the bug:
// Handle string-based categories automagically on elements
case $object instanceof \modElement && !($object instanceof \modCategory):
if (isset($data['category']) && !empty($data['category']) && is_numeric($data['category'])) {
$data['category'] = $this->getCategoryName($data['category']);
}
break;
That looks like the category name is just put in there for convenience reasons, to make the yaml file more readable. The bug is fixed by simply commenting that automagical translation out. If convenvience is still a thing, one could just write the array field "category_name" instead of "category".