Symptoms :
I have a very long vocabulary with hierarchies (for regions/countries). When displaying in the admin page (admin/content/taxonomy/xxx) only the first page shows any items - subsequent pages (eg. admin/content/taxonomy/xxx?page=2) show no items (even though there should be some).
Supposition :
I have looked at the code, and from what I can tell this will happen if :
1. The very first item is a root of a hierarchy
2. That hierarchy has more than one page's worth of elements
Patch :
Here is a patch I made for this. It fixes my problem.
Index: taxonomy.admin.inc
===================================================================
--- taxonomy.admin.inc (drupal 6.3)
+++ taxonomy.admin.inc (patched)
@@ -299,11 +299,13 @@
// Count entries before the current page.
if ($page && ($page * $page_increment) > $before_entries && !isset($back_peddle)) {
$before_entries++;
+ $term = next($tree);
continue;
}
// Count entries after the current page.
elseif ($page_entries > $page_increment && isset($complete_tree)) {
$after_entries++;
+ $term = next($tree);
continue;
}
@@ -314,18 +316,19 @@
$before_entries--;
$back_peddle++;
if ($pterm->depth == 0) {
- prev($tree);
+ $term = $pterm;
continue 2; // Jump back to the start of the root level parent.
}
}
}
$back_peddle = isset($back_peddle) ? $back_peddle : 0;
-
+
// Continue rendering the tree until we reach the a new root item.
if ($page_entries >= $page_increment + $back_peddle + 1 && $term->depth == 0 && $root_entries > 1) {
$complete_tree = TRUE;
// This new item at the root level is the first item on the next page.
$after_entries++;
+ $term = next($tree);
continue;
}
if ($page_entries >= $page_increment + $back_peddle) {
@@ -346,7 +349,9 @@
$root_entries++;
}
$current_page[$key] = $term;
- } while ($term = next($tree));
+
+ $term = next($tree);
+ } while ($term);
// Because we didn't use a pager query, set the necessary pager variables.
$total_entries = $before_entries + $page_entries + $after_entries;
(the problem is when it does the 'continue 2'. Just before that it does a prev($tree), knowing that the while test will do a next($tree) and thus get the element back. However, as this is the begining of $tree, prev($tree) tries to set a negative index and the subsequent call to next($tree) does not work.)
Thank you :)
Comment | File | Size | Author |
---|---|---|---|
#9 | patch_292073.diff | 1.69 KB | Alice Heaton |
Comments
Comment #1
Alice Heaton CreditAttribution: Alice Heaton commentedSorry, maybe I should have mentioned taxonomy on the issue title.
Comment #2
meba CreditAttribution: meba commentedThis is a duplicate of: http://drupal.org/node/23687
I have posted your patch there.
Comment #3
Alice Heaton CreditAttribution: Alice Heaton commentedHi Meba, thanks for you interest !
I'm wondering why you made my bug report a duplicate though ?
My report :
All this in accordance with the best practice bug reporting of Drupal, as per http://drupal.org/node/19279
Instead, you've made this issue a duplicate of an issue which :
Somehow, I feel the particular issue I'm reporting is more likely to be resolved on it's own... But maybe you know something I don't ? Could you let me know why you made this bug report a duplicate ? Thanks :)
Comment #4
damiancugley CreditAttribution: damiancugley commentedThis also affects the administration page for forums (since the forum hierarchy is represented with a vocabulary). In the case of our site, each container had exactly ten forums, just enough to make the pager go wrong :-)
I am changing the status back to 'patch (code needs review)' because I think this bug is unrelated to the new pager code mentioned in #23687: New pager code broken taxonomy pagers
Comment #5
Damien Tournoud CreditAttribution: Damien Tournoud commentedPlease see #302440: EOL Taxonomy Sprint: Taxonomy returns PDOException on "list terms" on clean HEAD install. I guess it may help.
Comment #6
catchAnselm - could you apply the 6.x patch from that issue and confirm whether it fixes your bug?
Comment #7
Alice Heaton CreditAttribution: Alice Heaton commented@catch : Thanks for asking - but no, it doesn't fix my problem. I've reverted my own patch, checked the issue was back (it was), and then applied the patch from #302440 (the one given in comment #17) ; I cleared the cache and checked again and it did not fix the issue.
The patch I've given, however, does fix my issue. I've spent a while analysing that problem when it occurred, and I am certain there is a logical error in the code of taxonomy_overview_terms ; which is fixed with my patch. I'm not sure why no-one is looking at that ; maybe I'm not expressing myself clearly ? I did give a test case, an analysis of the problem and a patch, not sure what else is needed...
Comment #8
catchThanks Anselm. I'm moving this to 7.x since it's likely the same issue is present there - and we usually fix in the development version then backport. You'll need to roll your patch into a proper patch file to get it reviewed properly - cvs diff -up > foo.patch will do it, or see http://drupal.org/patch/create
Comment #9
Alice Heaton CreditAttribution: Alice Heaton commentedThanks catch :)
Here is the patch as a patch file ; unified format and with function name :)
Comment #10
meba CreditAttribution: meba commentedI don't think this patch solves the problem, maybe partially. I applied to 6.x and after clicking page 2, terms from page 1 are still displayed, however - together with terms from page 2. then, page 3 displays only terms from page 3.
Comment #11
catchmeba - that's by design - are some of the terms greyed out?
Comment #12
meba CreditAttribution: meba commentedNo...
Comment #13
Alice Heaton CreditAttribution: Alice Heaton commented@meba : I agree with catch - I think what you are seeing is by design. The taxonomy admin page never splits hierarchies, so when an item has sub items you always see them all together. It might depend on the template you're using, but with the default one the items that are not of the current page are slightly greyed out.
For instance if your first item has, say, 50 sub items then :
Only when you get to the sixth page does this term and all it's sub-items go away.
It may or may not be the right approach in terms of UI, but it's what it's supposed to do. For dealing with large taxonomies, you might find Taxonomy Manager to be helpful.
Comment #14
meba CreditAttribution: meba commentedi understand and agree...
Is it possible to page the list by term? I mean that not depending on number of terms, one term always displays its children - all of them. I am aware that this may require some extensive algorithm, but its an idea which may male the interface more undersandable.
If its not, this patch looks good to me.
Comment #15
Alan D. CreditAttribution: Alan D. commentedI just ran into this issue with a moderately large vocab of 50,000 items. The patch worked on the pagination issue, but 20,000 or so items on a page makes the jscript unusable / crashes the browser even on a fairly powerful computer. The current admin interface is not really up to this sort of taxonomy.
Comment #16
natukSubscribing
Comment #17
xmacinfoWhile it will be great to have this fixed for D7.x (which I shall test when I'll have some free time), I do expect a backport later for D6.x.
As for D6.17, currently, with a large taxonomy list, we cannot go to page 2 (admin/content/taxonomy/xxx?page=1).
But we can display any other pages:
For example, going to page 1(admin/content/taxonomy/xxx) or page 3 (admin/content/taxonomy/xxx?page=2) or page 4 (admin/content/taxonomy/xxx?page=3) and so on..., the content is displayed properly.
@Anselm Heaton: thanks for the Taxonomy Manager suggestion. I will try it as well.
Comment #18
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedI have too suffered through this. Would be great to see a d6 solution at some point. IMO, this is a very big deal and it breaks the normal functionality of the taxonomy module. I think it should be marked critical since it renders taxonomy module broken for some use cases.
Comment #19
Alan D. CreditAttribution: Alan D. commentedNot critcal, but fairly major in relation to most existing bugs that exist in Drupal 6/7
Comment #20
sunNot major.
Comment #21
ytsurkthis is still encountering ..
see also #1217046: Clean up the CSS for Taxonomy module
Comment #22
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedI don't really see how this is not minimally major and more likely critical since it breaks the normal expected functionality of taxonomy administration in Drupal core.
Comment #23
xmacinfoFor very large Taxonomy lists, is recommended to use this module :
http://drupalmodules.com/module/taxonomy-manager
I agree that this bug should be fixed in core. But for now, using Taxonomy Manager save us a lot of performance problems.
Comment #24
docans CreditAttribution: docans commentedHi. I am experiencing this issue in Drupal 7.24. when i go to the next taxonomy page(second page) i.e.
http://mysite/admin/structure/taxonomy/catalog?page=1
nothing shows up. And this has also affected my ubercat catalog functionality as well. Is ther a patch for drupal 7.24 as at nowComment #25
docans CreditAttribution: docans commentedComment #26
Alan D. CreditAttribution: Alan D. commentedNeeds to be fixed in Drupal 8.x before it has ANY chances of making it into Drupal 7.x :(
Comment #27
docans CreditAttribution: docans commentedThanks very much for your reply
Comment #28
andypostseems duplicate of #763380: Do not use \Drupal\taxonomy\TermStorageInterface::loadTree() in \Drupal\taxonomy\Form\OverviewTerms::buildForm()
Comment #29
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedThis is related to #242324: Going to page 2 on "list terms" page doesn't display additional terms as well.
Comment #30
gambryAs mentioned on #29closing this issue as it duplicates #242324: Going to page 2 on "list terms" page doesn't display additional terms