I was having problems with a category that had multiple parents support: It kept adding the container to the parent list when creating a category.

I finally tracked this down to the use of $node->parents[0].

It seems that when the multiple-select list is used (i.e. activeselect isn't installed,) the $node->parents array ends up looking like this:

array(
  73 => '73',
  82 => '82',
);

instead of this:

array(
  0 => '73',
  1 => '82',
);

(although I haven't tested how it works with activeselect)

so, of course, $node->parents[0] doesn't exist, even though there ARE parents selected.

After applying this patch (attached) to de-key the $node->parents array, I am able to create categories without them having the container as a parent.

Comments

Bèr Kessels’s picture

I ran into the same issue.
Though I am not sure about whether or not this is the proper solution (I understand too little of category) It /does/ fix the bug.

Bèr Kessels’s picture

FWIW, this patch fixes the "SQL error" bug #70229 too, it seems.

bdragon’s picture

In my opinion, the "most proper" way of handling this would be to have the form give the user the option to specify the "primary parent" of a category directly, instead of always (well, trying to, at least) selecting the first one in the parents array.

Then, during form validation, ensure that parent (not to be confused with parents[]) has a sane value. If the user didn't specify one, grab the first one out of the parents[] array as before.

I just noticed there's actually a piece of code in category.inc:category_get_form that tries to let the user specify the primary parent by hand:

  if ($set_default) {
    $form['parent'] = array(
      '#type' => 'value',
      '#value' => $node->parent,
    );
  }

It will never kick in, though, because the function doesn't ever get $set_default from anywhere. It also isn't very user friendly.

How about a collapsed fieldset with title "Primary parent (optional)" that contains a subform to single-select a parent, with the subform defaulting to "<automatic>" or something if parent isn't set? During validation, if the user chose a primary parent that wasn't selected in the main parents[] selection, add it to the parents[] array.

That would allow the removal of all the instances of parents[0] in the code, I believe, and be both more flexible and less prone to error.

I could make a patch for this if anyone's interested.

drurian’s picture

Can you make it please?

bdragon’s picture

It appears that my "most proper" suggestion is flawed, and this is indeed just a simple bug.

After reading the code, I see that the order of parents is determined by a) The parent containers' weight, and then b) The parent containers' title. Then this information is thrown away (another bug, it re-sorts by CID accidentally).

The elegant way of allowing parent ordering per category would be to add a weight field to {category_hierarchy} and add h.weight to the beginning of the ORDER BY clause in category.inc:category_get_parents.

Right now though, I'll write a patch to fix what I percieve as being the intended behavior: The lowest-weight category will be the primary parent.

bdragon’s picture

StatusFileSize
new1.28 KB

Here's the patch.

All the changes are in category.inc.

I changed category_get_parents to honor sorting, which made it an indexed array.

I changed an instance of relying on category_get_parents to return cid's as the keys.

Any instances of

$parents = array_keys(category_get_parents($node->nid));

need to be changed to:

$parents = category_get_parents($node->nid);
for($i=0;$i<count($parents);$i++){
  $parents[$i] = $parents[$i]->cid;
}

This probabaly fixes odd sorting bugs in the category chooser as well.
Please test.
Thanks.
--Brandon

bdragon’s picture

Title: $node->parents[0] doesn't work properly without activeselect » category_get_parents -- sort fix (was: $node->parents[0] doesn't work properly without activeselect)
Assigned: Unassigned » bdragon
Priority: Normal » Critical

(updating title, raising priority, assigning to self)

bdragon’s picture

I need to check category_display, category_export, category_legacy, category_menu, and contrib still.

I'll make patches as I go along.

bdragon’s picture

Category_display:
0 modifications needed.
1 bug fixed just from having the new code in:

        if (is_array($node->parents)) {
          $parent_obj = $node->parents[0]; <-- broken before patch.
          if (!empty($parent_obj)) {
            $parent = _category_display_navlinks($parent_obj, 'get_parents', $node);
            if ($parent) {
              drupal_add_link(array('rel' => 'index', 'href' => url('node/'. $parent->cid)));
              $links .= l(t('up'), 'node/'. $parent->cid, array('class' => 'page-up', 'title' => t('Go to parent page')));
            }
          }
bdragon’s picture

category_export:
0 modifications needed.
0 bugs fixed.

category_menu:
0 modifications needed.
Possibly many bugs fixed.
Seen:
Assumption in menu logic, Probabaly causing missing or broken menus. (line 215.)
Evidence of a bug workaround seen (line 226) (may be removed now)
Same workaround on (line 333)
Possible bug on (line 369)

bdragon’s picture

contrib/cac_lite:
0 modifications needed.
0 bugs fixed.

contrib/category_bulkedit:
0 modifications needed.
Possible bug on line 502.

contrib/category_outliner:
0 modifications needed.
0 bugs fixed.

contrib/category_pathauto:
0 modifications needed.
0 bugs fixed.
Workaround found on line 84.

contrib/category_transform:
0 modifications needed.
possible bug on line 175, fixed by patch.

contrib/category_views:
0 modifications needed.
0 bugs fixed.

bdragon’s picture

StatusFileSize
new1.57 KB

Last but not least, category_legacy:

category_legacy_build_category_from_term appears to key the parents array too.
This could possibly cause terms to get forced to have the container as a parent during import.

Possible bugs on lines 1319 & 1409.

Here's a patch to de-key category_legacy_build_category_from_term. I don't have anything to test it on.

In addition, $parent_map should be passed by reference for speed. I also updated the doxygen documentation for the functions that use a $parent_map.

venkat-rk’s picture

Which of these three patches (the one in the original post, #6 and #12) should be applied? Or should all the patches be applied? In any particular order? I am willing to test this out.

Could you please provide category_array_fix.txt as a patch file?

bdragon’s picture

The patches to apply are #6 and #12. Order isn't important.
OP fixed a problem where the container would get added to the parents list in a container with hierarchy set to "multiple."
#6 supersedes OP. It changes the behavior of category_get_parents to return a non-associative array that is sorted properly.
#12 makes category_legacy create de-keyed arrays like the new behavior of category_get_parents.

category_array_fix.txt is in fact a patch file, I just screwed up the file extension when I made it.

I'm expecting the sorting in the parent selector to be different than pre-patch, as sorting was previously broken in category_get_parents. Adding weight to categories will make them move around in the list. Also, a category with multiple parents will have the first match as its primary parent.

I'm hoping this fixes more bugs than it introduces.

venkat-rk’s picture

Thank you bdragon. I am going to jump into this headlong. I have invested too much time in category module not to. I rarely use multiple parents, but do use category_legacy frequently and hope this will solve the bugs. I experienced the category_hierarchy bug just today when using category_legacy.

venkat-rk’s picture

StatusFileSize
new1.4 KB

I applied both the patches. Now, when I create a container, I can see the container hierarchy in the parent select drop-down. I don't remember having seen this earlier. Is this correct?

In the attached screenshot, 'Find' shows up as the child container of 'Find Section', a hidden container. This is exactly the way I set it up. I don't remember this ever having worked this way.

Yet to test category_legacy. Unfortunately, I trashed a large test site built on taxonomy so I don't have much data. Will create another test site and report this later.

venkat-rk’s picture

On a hunch, I decided to try category_pathauto, which has been broken for the last month or so after applying these patches. Good news- it works. No more problems as reported in the issue queue.

Bulk update still has problems creating the correct category paths, as does the creation of an alias when you manually remove the exisitng one from the 'Url path settings' field, but it works cleanly by and large.

bdragon’s picture

I applied both the patches. Now, when I create a container, I can see the container hierarchy in the parent select drop-down. I don't remember having seen this earlier. Is this correct?

Well, as far as I know, without the patch, parents were getting sorted by id, so it was possible to end up with things in the wrong order, like

  • <root>
    • Find *
  • Find Section *

In the attached screenshot, 'Find' shows up as the child container of 'Find Section', a hidden container. This is exactly the way I set it up. I don't remember this ever having worked this way.

Was "Find Section" supposed to disappear from the list?

On a hunch, I decided to try category_pathauto, which has been broken for the last month or so after applying these patches. Good news- it works. No more problems as reported in the issue queue.

That's good to hear.

I'm most curious about category_legacy. I wasn't able to test my changes to it (no legacy data), and I'm not familiar with what's "normal," as I haven't actually used it before.
--Brandon

venkat-rk’s picture

Well, as far as I know, without the patch, parents were getting sorted by id, so it was possible to end up with things in the wrong order, like

*
o Find *
* Find Section *

I don't really remember as I haven't been using category for about a month now.

The 'Find' container wasn't meant to disappear, so everything is working as it probably should. May be I should test category without the patches on another site to find out the exact differences. I will try and set up a test site for category_legacy as I am curious about it too.

venkat-rk’s picture

I want to add that while these patches have made category less buggy, the category map problem still persists. Unfortunately, I wasn't paying attention to what I was doing, so I am unable to report the exact sequence that caused the error.

category_pathuto is still largely broken (edit a container/category or node- pathauto will report the alias as having been created but nothing happens really. Only works when you manually enter the alias and save), but I will report that in its own issue.

venkat-rk’s picture

One problem after applying the patch:

If I have a regular or free tagging category under a hidden container and I create a node tagged with that category, this category is not picked up during breadcrumb generation.

As a result, on the node page view, one gets just the 'Home' link in the breadcrumb trail. This breaks the hierarchical menu tree generated by cat_menu too.

At least, this is how the problem appears at first glance. Screenshots to follow.

venkat-rk’s picture

StatusFileSize
new31.73 KB

In the attached screenshot, the node has been tagged with the category 'News' which is under a hidden container. Notice that the 'News' link is not shown in the breadcrumb trail.

venkat-rk’s picture

StatusFileSize
new6.61 KB

The container in question here is 'Spirituality'. It has a hidden container called 'Site Sections' as its parent. 'Discourses' and 'Festivals' are categories created by free tagging. The node displayed in the sceenshot is tagged with both the categories. All good so far.

venkat-rk’s picture

StatusFileSize
new15.76 KB

Everything breaks on the node view. See the collapsed cat_menu tree on the left and the absence of breadcrumbs at the top. It is not an url alias issue, as you can see from the url in the browser.

venkat-rk’s picture

StatusFileSize
new9.17 KB

From what I have seen so far, the issue seems to be only when hidden containers are used. For a container directly under root, the breadcrumbs are correctly generated.

See attached screenshot where the container 'Projects' is directly under root.

bdragon’s picture

Looking into this now.

Will re-evaluate category_menu for side effects involving hidden containers.

bdragon’s picture

What happens if you mess with the weight of the hidden container?

venkat-rk’s picture

Thanks for looking into this.

I just tried changing the weights of the hidden containers around. For good measure, I resaved the nodes tagged with categories in those containers. It didn't help, unfortunately.

bdragon’s picture

StatusFileSize
new1.03 KB

Found a *potential* error: Only the first parent was being checked here.
Does this make things better or worse?

venkat-rk’s picture

Thanks for the quick assistance. Much appreciated. It is past midnight here, though, so I will report back tomorrow after tyring the patch:-)

bdragon’s picture

I modified "category_breadcrumb.module" to get breadcrumbs working nicely.
http://drupal.org/node/75276#comment-134905

It _should_ take the lightest weight path back up to the root. I have not extensively tested all this, but it appears to work.

Right now I'm too tired to test this further. Please tell me if this solves your problem.

--Brandon

venkat-rk’s picture

StatusFileSize
new8.41 KB

I applied the patch and resaved the nodes in question, but with no apparent effect. The problem remains.

I am loath to applying the category_breadcrumb.module as it is in the 'wild' at the moment and because category otherwise never has a problem with generating correct breadcrumbs.

venkat-rk’s picture

I also tried the following, resaving the nodes on each occasion, but without results:

1.) Changed the weights of the free tagged categories to both positive and negative values instead their current 0
2.) Changed the depth of the free tagged categories to an infinite value (-1) even though they didn't have child categories
3.) Changed the depth of the hidden, top level container that holds all the site's containers to an infinite value (-1)

bdragon’s picture

Ahh.

No wonder I couldn't figure out where the breadcrumbs were coming from. I totally forgot about category_pathauto.

I suspect if I check for bugs in category_pathauto, I may find a proper solution to this.

bdragon’s picture

StatusFileSize
new1.02 KB

does this patch change things?

If it does, I believe I have a very good idea of what's wrong.

venkat-rk’s picture

StatusFileSize
new15.42 KB

Whoops! Some bug here.

A few things are noticeable:

1.) The patched cat_pathauto now leaves out the container (musings) from the alias and takes the first category. But the browser url points to the full path
2.) The breadcrumb still doesn't reflect the full hierarchical trail- 'Frugality' is missing

venkat-rk’s picture

StatusFileSize
new1.95 KB

Most interesting.

If I click on the edit link of the node that showed the error and look at the url path settings, it shows the full path (including 'musings'). This is contrary to the message that pathuto printed out to screen.

bdragon’s picture

Right. I wasn't fixing the general case. I was only fixing _category_pathauto_get_path, and only for the case where the issue was with the immediate parent.

The underlying problem appears to be an assumption in category_location that following the chain of $node->parent is "good enough" to find the root.

Rewriting category_location to "try harder", so to say, should fix all of this for good.

bdragon’s picture

Well, THIS is interesting:

Checking the return value of category_location:

array(3) {
[0]=>  object(stdClass)(7) {
["cnid"]=>  string(1) "0" 
["description"]=>  string(0) "" 
["weight"]=>  string(1) "0" 
["depth"]=>  string(1) "0"
["title"]=>  string(9) "Bug Check" 
["nid"]=>  string(4) "1460" 
["parent"]=>  int(0) } 

[1]=>  object(stdClass)(7) { 
["cnid"]=>  string(4) "1460" 
["description"]=>  string(0) "" 
["weight"]=>  string(1) "0" 
["depth"]=>  string(1) "0" 
["title"]=>  string(15) "Parent category" 
["nid"]=>  string(4) "1461" 
["parent"]=>  string(4) "1460" }

[2]=>  object(stdClass)(7) { 
["cnid"]=>  string(4) "1462" 
["description"]=>  string(0) "" 
["weight"]=>  string(1) "0" 
["depth"]=>  string(1) "0" 
["title"]=>  string(11) "Test subcat"
["nid"]=>  string(4) "1463" 
["parent"]=>  string(4) "1462" 
}

Note the parent of the last object. It is pointing to *itself*

This may also be what's causing the "duplicate category at end of list" problem with nodes.

Hopefully I can figure out why this is happening...

bdragon’s picture

*slaps forehead*

It's not pointing to itself, it's pointing to the container that was left out due to being hidden.

bdragon’s picture

Ok, now that I actually know how pathauto works (sigh)

array(5) {
["[container]"]=>  string(0) ""
["[categorypath]"]=>  string(0) ""
["[containerfirst]"]=>  string(8) "yahidden"
["[categoryfirst]"]=>  string(9) "rightside"
["[categorypathfirst]"]=>  string(49) "Bug_Check/bpc/leftside/rightside/yey_more_testing"
}

The real problem is containerfirst being the wrong container, causing pathauto to not be able to find the correct path.

bdragon’s picture

category_pathauto_get_placeholders needs to take into account hidden containers. $node->cnid may not be a valid point on the menu.

Will think about this further.

bdragon’s picture

Ok, after thinking about it a bit, I realized that it may be impossible to unambiguously identify nodes without having hidden containers in the path.

Consider:

-News*
--Sport[hidden]*
---Baseball
---Basketball
--Something[hidden]*
---Aardvarks
---Baseball
--Baseball

Node 1: title "An Article" categories{Sport=Baseball}
Node 2: title "An Article" categories{News=Baseball}
Node 3: title "An Article" categories{Something=Baseball}

Which node do I mean when I ask for /news/baseball/an_article?
Which container is responsible for the path /news/baseball?

venkat-rk’s picture

I am just as stumped by the pathauto stuff, but I don't have your level of technical understanding even to suggest something:-)

One other issue I noticed with these patches (only #0, #6 and #12). If I click on create content and try to add a category under <root>, I can't! I am forced to put it under some existing container or create one just for this purpose.

I am a little confused as I think the default behaviour of category module is different and let you add a category under root. Might be wrong, though.

bdragon’s picture

Well, my last question is more of a classification question than a technical question.
My thoughts:

  • A URL can only refer to one resource.
  • The directory path in the URL is a hierarchy.
  • By letting certain entities in Drupal "own" pieces of the hierarchy, behavior can be delegated to those pieces, who are more likely to be able to keep track of themselves than having a central registry for everything (not to mention dynamic paths, etc -- Really wouldn't want to be storing that kind of stuff...)
  • When you start hiding things from the path, you suddenly lose the ability to unambigiously identify things.
  • This also happens with menu items, but each item can store additional data, so they can work around the missing information, whereas URLs can't store any data transparently (i.e. you always see all the information).
  • This missing information in the URL case causes Drupal (actually, pathauto, but this is a simplification) to become confused about what code is responsible for a certain path.
  • The confusion can lead to things like the breadcrumb disappearing.

Possible solutions?

  1. Walk up the tree of parents until we find a container that isn't hidden, and tell pathauto that is our container is that one.
    • This doesn't seem like a good solution to me, but I've dug so far into the code that I can't see the forest from the trees anymore.
    • What happens if a hidden container is in two containers?
      • (Multiple parents is HARD. The whole weights thing is an easy way out for things that *can't* handle multiple parents.)
  2. Don't leave the hidden container out of the URL path.
    • This makes the hidden container less hidden, which isn't good.
    • I don't know how acceptable this tradeoff is.

Deeper thoughts, meta-thoughts.

I'm not an expert in classification. I'm not an expert in SEO. I can't see the big picture. I'm not an architect. I'm just a coder in the trenches. As such, I don't know what the *expected* behavior is.

Ramdak: What would fufill the "principle of least suprise" for you? I.E. in a perfect world, what would you expect to happen when you put an item in a category in a hidden container? How would the menu look? How would the URL look? How would the breadcrumb look?

I have seen the code. I am biased. Any solution I propose is likely to be in terms of the code already written. It would be a tragedy to trade one tradeoff for another when a superior solution existed all along, but everyone with the skill to implement it was so locked into the mindset of the current code that they never realized it.

Are hidden containers the solution? Is there a better way?

Back to normal
Sorry about the philosophy there, but I really needed to say it. :)

While I have the capacity to find bugs in code, I don't really have the capacity to find bugs in processes.

--Brandon

venkat-rk’s picture

This missing information in the URL case causes Drupal (actually, pathauto, but this is a simplification) to become confused about what code is responsible for a certain path.

Ramdak: What would fufill the "principle of least suprise" for you? I.E. in a perfect world, what would you expect to happen when you put an item in a category in a hidden container? How would the menu look? How would the URL look? How would the breadcrumb look?

Bdragon, I stepped away from this a bit to get some perspective. But, to respond:

1.) When category_pathauto was initially released on 1st June, it worked perfectly with hidden containers- they would ignore those containers and display perfect urls and breadcrumbs. And, although I frequently got the duplicate entry error for category_map or category_menu, distant parents worked fine in conjuction with cat_pathauto. I can say this for sure because I tested a lot

The problems began to surface around mid-July I think when category_pathauto broke. I don't know if this is because of changes to that module or to category. I would hazard a guess that it is the latter.

2. ) To respond to your question- I think my comment above perhaps answers it:-)

I would expect a hidden container to stay hidden because it is there for creating structure, not for categorisation and it is this combination that category module set out to achieve (and almost has), to put things rather simplistically. So, when I use hidden containers and cat_pathauto in conjunction, as a lay user, I expect the hidden containers not to show in the breadcrumbs and cat_pathauto to ignore them and still build correct urls that traverse the category hierarchy (which obviously includes the hidden containers).

I think hidden containers is one of the most important features of the module. One simple example - with it, you can have a category hierarchy that has several child containers each meant for content related to only one node type and taggable by categories relevant only to those node types. By simply placing a hidden container as the parent of each child container in the hierarchy and then creating specific categories as children of that child container, the node form for tagging that content type presents a great improvement for the end user. This isn't possible with core taxonomy- node types can be only defined at the vocabulary level globally as there is no concept of child vocabularies.

In sum, it appears (I haven't rigorously tested it) that the regular category module, despite its many duplicate entry error issues, doesn't have a problem generating correct breadcrumbs and menu items when hidden cotainers are used. However, since mid-July, category_pathauto is broken.

Your patches fix many underlying bugs *and* makes category_pathauto work again, but make breadcrumbs for categories and containers under hidden containers disappear from the breadcrumb, thus breaking the tree view of the cat_hierarchy at node level. Sigh:(

I want to reiterate again that your help has made working with category module possible in Jaza's absence.

bdragon’s picture

StatusFileSize
new521 bytes

It's 2AM right now here, but I thought I should probabaly follow up with a quick note before going to bed.

(quick note it was not -- ended up doing about half an hour of research....)

Mid July.... Mid July.... I'm betting July 10. There were multiple changes with the menu stuff on July 10.

This one makes me wonder:

Revision 1.55
Mon Jul 10 09:01:36 2006 UTC (2 months, 1 week ago) by jaza
Branch: MAIN
Changes since 1.54: +8 -1 lines
Diff to previous 1.54

- Changed category_node_save() to flatten the category array before returning. As such, category_pathauto is now able to properly handle saving the alias for nodes with assigned categories (including with free tagging categories).

I wonder what would happen if you tried THIS. (This patch should neutralize the change from the above commit.)

It's 2:30 now. I really need to get some sleep. Next week is finals week, so I may be a bit less responsive than I have been lately, but I'll keep working on this when I find time.

Jaza’s picture

Title: category_get_parents -- sort fix (was: $node->parents[0] doesn't work properly without activeselect) » category_get_parents indexing changes
Status: Needs review » Reviewed & tested by the community

I have committed the patches submitted by bdragon in #6, #12, and #29 to HEAD and 4.7. I also committed a few other changes that were needed to make this new version of category_get_parents() work properly, such as changes to the activeselect callback implementation, and changes to the taxonomy wrapper.

Thankyou very much Brandon (bdragon) for your hard work in debugging and patching this issue. I think that your solution provides a more reliable and consistent system for category_get_parents(), and it's clear that it has fixed quite a few category module bugs in one fell swoop. Just how many bugs (and which ones), I'm not quite sure. Thanks also to Ramdak for your testing and feedback in this thread.

I've done a fair bit of testing of this patch (along with my changes), and I wasn't able to find any new problems that it introduced. However, my testing was not particularly extensive. For this reason, I have marked this patch 'ready to be committed' (although it already has been committed) - to indicate that testing of the updated category module is needed, and that further patches may be needed in order to 'clean up any damage' that may have been done as a side effect of this patch going in.

btw, bdragon, I see no reason why I should commit your latest patch in #47, which attempts to undo a bug fix that I committed a while ago. If you can provide some further insight into why you think the $cats_flat thing should be removed, please post your patch and reasoning in a separate thread. Thanks.

bdragon’s picture

btw, bdragon, I see no reason why I should commit your latest patch in #47, which attempts to undo a bug fix that I committed a while ago. If you can provide some further insight into why you think the $cats_flat thing should be removed, please post your patch and reasoning in a separate thread. Thanks.

You are absolutely correct. #47 is not meant to go into CVS, and it does attempt to undo a bugfix. I should have posted it inline instead of attaching it. Sorry about that.

I've been trying to figure out why breadcrumbs stopped working properly when hidden containers+category_pathauto were used, and #47 was an attempt to see if the $cats_flat stuff was the culprit. TBH, the hidden container stuff in this thread probabaly belongs in a seperate issue completely, but it got mixed in with this issue because I originally thought it was fallout from my changes.

bdragon’s picture

I created a new issue to continue discussion on the breadcrumb & hidden container problems.
http://drupal.org/node/84643

Ken Watts’s picture

I think what just happened to me is related to this thread. I should warn you that I'm really new at this, so I'm never sure if my problems are bugs or newbie functions.

I set up a site in a development environment that was working perfectly. As part of that site, I had put the following code into the category.inc file:

function parenti_title($node) {
if ( ! $node || ! $node->parent ) {
return '';
}

$node = node_load(array('nid' => $node->parent));

return $node->title;
}

I'm not at all sure that was the right place to put it, but I tried several other locations, and that was the only one that worked. It allowed me to use the parent name within a node by inserting the following code:

f ($is_front) {
$parenttitle = parent_title($node);
print $parenttitle;
print t(": ");
}

It worked perfectly.

But when I started to set up my site on a hosted server, I used the most recent version of drupal, and the most recent version of the category module (9/17/06).

Now I have two problems, which I think may be related to this thread.

First, drupal recognizes the function, but it doesn't find a parent (I put a message between the single quotes in the function, to test this. The message prints to the page, where I used to get the name of the parent category.)

Second, when I adusted the weight on one of my categories, and clicked on "Save categories and containers" on the category page, I got the following error messages.

Duplicate entry '2-3#' for key 1 query: INSERT INTO category_cont_distant (cid, allowed_parent) VALUES (2, '3#') in /home/dailymull/domains/dailymull.com/public_html/dev/includes/database.mysql.inc on line 120.

Duplicate entry '2-0' for key 1 query: INSERT INTO category_cont_distant (cid, allowed_parent) VALUES (2, '0') in /home/dailymull/domains/dailymull.com/public_html/dev/includes/database.mysql.inc on line 120.

Duplicate entry '1-0' for key 1 query: INSERT INTO category_cont_distant (cid, allowed_parent) VALUES (1, '0') in /home/dailymull/domains/dailymull.com/public_html/dev/includes/database.mysql.inc on line 120.

Duplicate entry '1-0' for key 1 query: INSERT INTO category_cont_distant (cid, allowed_parent) VALUES (1, '0') in /home/dailymull/domains/dailymull.com/public_html/dev/includes/database.mysql.inc on line 120.

My apologies if this is a red herring, but it seems to fit the pattern in this and related threads.

Thanks

Ken Watts’s picture

Sorry--correction: the version of the category module I'm using is 9/19, not 9/17.

Ken Watts’s picture

Okay, I think I'll stop making these posts until I know more.

The problem with the function was my fault--I had some settings wrong. So that has nothing to do with this thread, and I apologize.

The error messages still seem to be connected, as far as I can see now.

marcoBauli’s picture

Just tryed the latest 4.7 release with category_get_parents fixes, and seems to work.
Also combined with the category_breadcrumb.menu at http://drupal.org/node/75276 outputs nice breadcrumbs that reflect the category hierarchy (with previous versions that didn't work).

I didn't deep test (not more than 20 minutes) but wanted to write this rather than forgetting to give any feedback.

venkat-rk’s picture

StatusFileSize
new15.05 KB

The duplicate entry issue is alive and kicking. It hit me a while ago when I tried to convert a taxonomy based site to category by using category legacy to import the stuff. I downloaded and installed the category module just a few minutes ago, so this bug is still there in the latest version.

Jaza, Bdragon, should I submit an issue against category_legacy or will this do?

bdragon’s picture

Sorry about that, Ramdak.

I totally spaced it. The patch in the *original post* was the patch to fix the duplicate parents issue, and it never got in.

Please check http://drupal.org/node/92818 for an updated copy of the patch.

Jaza’s picture

Status: Reviewed & tested by the community » Fixed

Marking this issue fixed, since http://drupal.org/node/92818 has now gone in, and since nobody has reported any problems specifically related to the commit announced in #48 (above).

venkat-rk’s picture

@bdragon: Thanks. Does this mean that the fix in http://drupal.org/node/92818 committed by Jaza takes care of this and the problem reported in the other thread?

Thanks.

bdragon’s picture

It will take care of the duplicate entry problems. The hidden container problem may still exist though...

Anonymous’s picture

Status: Fixed » Closed (fixed)
summit’s picture

Title: category_get_parents indexing changes » category module and localizer dublicate entry
Status: Closed (fixed) » Active

Hi,

I open this bug report again.
I am using the latest category module (version v 1.100.2.26 2007/02/02).
When making a translation with localizer module. I get the duplicate entry error with category_cont_distant:
Duplicate entry '590-0' for key 1 query: INSERT INTO BEST_INFO_category_cont_distant (cid, allowed_parent) VALUES (590, '0') in /home/beontop/domains/agim.nl/public_html/includes/database.mysql.inc op lijn 120.

Please help.
Thanks in advance,
greetings,
Martijn
www.best-information.eu

sun’s picture

Title: category module and localizer dublicate entry » category_get_parents indexing changes
Status: Active » Closed (fixed)

Please open a new issue for that. This thread is far too long to maintain.