- π©πͺGermany Grevil
We just ran into this issue migrating a Drupal 7 website with a large taxonomy to Drupal 10. So this is still important to fix, as it breaks large sites. Reading the comments above, I think we still need a plan on how to fix this deep underlying issue, before we invest more time in code here?
- π¦π·Argentina cesarmiquel
Not sure why this issue derailed. The patch in #45 π Avoid loading all terms on the taxonomy overview form RTBC worked for me in several tests/sites with large taxonomies and had the blessing by Catch β . All that remained was to add a comment. In all honesty I didn't understand exactly what the comment was but I believe once that comment is added this was RTBC.
There is also a version for 10.x. in #54 π Avoid loading all terms on the taxonomy overview form RTBC . I recommend you test that version and leave a comment if it works.
I don't recommend the solutions that try to increase the memory size as suggested as they will eventually break. The proposed solution worked for me on two large sites I tested.
- π¨π³China hongqing
Patch #54 works well with the latest Drupal 10.0.9. Thanks.
- First commit to issue fork.
- last update
over 1 year ago 29,416 pass - @plopesc opened merge request.
- Status changed to Needs review
over 1 year ago 2:56pm 5 June 2023 - last update
over 1 year ago 29,416 pass - πͺπΈSpain plopesc Valladolid
- Status changed to Needs work
over 1 year ago 5:23pm 5 June 2023 - πΊπΈUnited States smustgrave
As a bug will need a test case showing the issue please
Thanks!
- Status changed to Needs review
over 1 year ago 10:46am 6 June 2023 - last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago 29,416 pass, 1 fail - πͺπΈSpain plopesc Valladolid
Thank you for the heads-up smustgrave.
Attaching new version of the patch including tests and improving the load terms logic for the submit handelr as well.
- last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago 29,418 pass The last submitted patch, 67: 2183565-67-test-only.patch, failed testing. View results β
- last update
over 1 year ago 29,418 pass - Status changed to RTBC
over 1 year ago 7:22pm 8 June 2023 - π³π±Netherlands bbrala Netherlands
smustgrave β credited bbrala β .
- πΊπΈUnited States smustgrave
Giving credit to bbrala for pointing me out to a good way for doing a profile using ddev and phpstorm.
Using devel generate created 1000 terms and went to the taxonomy overview page of my vocabulary
Attaching before/after
Before
After
So seeing a slight faster render.
- last update
over 1 year ago 29,437 pass - last update
over 1 year ago 29,438 pass - last update
over 1 year ago 29,443 pass - last update
over 1 year ago 29,449 pass - last update
over 1 year ago 29,487 pass - last update
over 1 year ago 29,500 pass - last update
over 1 year ago 29,506 pass - last update
over 1 year ago 29,537 pass 8:25 4:59 Running- last update
over 1 year ago 29,560 pass - last update
over 1 year ago 29,564 pass - last update
over 1 year ago 29,572 pass - last update
over 1 year ago 29,572 pass - last update
over 1 year ago 29,802 pass - last update
over 1 year ago 29,803 pass - last update
over 1 year ago 29,803 pass - last update
over 1 year ago 29,806 pass, 2 fail The last submitted patch, 69: 2183565-69.patch, failed testing. View results β
19:06 13:37 Running- Status changed to Needs work
about 1 year ago 9:08am 21 September 2023 - π¦πΉAustria golubovicm
Patch 2183565-69.patch is not working for me. Still getting:
Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 4096 bytes) in /var/www/web/modules/contrib/taxonomy_menu/src/TaxonomyMenuHelper.php on line 104
Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 24576 bytes) in Unknown on line 0 Hi :)
Since 9.4 all my taxo more big 2000 is block, I put this patch and works now:
https://www.drupal.org/project/drupal/issues/3327118#comment-15252799 π Chunk multiple cache sets into groups of 100 to avoid OOM/max_allowed_packet issues FixedBut, all big content is still block: Error Vanish cache server.
I can not make Sitemap too for big content, Drupal 9.4 break all web site... :(
- last update
about 1 year ago 28,527 pass - last update
about 1 year ago 29,655 pass - last update
about 1 year ago 28,526 pass - last update
about 1 year ago 28,508 pass, 10 fail - Status changed to RTBC
about 1 year ago 10:35am 18 October 2023 - πΈπ°Slovakia poker10
Moving back to RTBC (per #71) - there was a random failure.
- last update
about 1 year ago 30,418 pass - last update
about 1 year ago 30,421 pass - Status changed to Needs review
about 1 year ago 7:52pm 21 October 2023 - π¬π§United Kingdom catch
+++ b/core/modules/taxonomy/src/Form/OverviewTerms.php @@ -520,9 +527,10 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // Build a list of all terms that need to be updated on previous pages. $weight = 0; - $term = $tree[0]; - while ($term->id() != $form['#first_tid']) { - if ($term->parents[0] == 0 && $term->getWeight() != $weight) { + $raw_term = $tree[0]; + while ($raw_term->tid != $form['#first_tid']) { + if ($raw_term->parents[0] == 0 && $raw_term->weight != $weight) { + $term = $this->storageController->load($raw_term->tid); $term->setWeight($weight);
I think it would be worth building the list of term IDs in advance, and then using ::loadMultiple() here.
Similar in the next hunk of the MR too.
Otherwise looks good though.
- last update
about 1 year ago 30,427 pass - πͺπΈSpain plopesc Valladolid
Good point.
Added new version of the patch storing in an index all the entities and their weight to load all of them in a single call afterwards.
- last update
about 1 year ago CI aborted - πΈπ°Slovakia poker10
There are no test failures in the patch #77, but I am curious how is the while loop supposed to work now, as the
$raw_term
variable is not being changed at all?@@ -526,14 +533,13 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $weight = 0; + $raw_term = $tree[0]; + $term_weights = []; + while ($raw_term->tid != $form['#first_tid']) { + if ($raw_term->parents[0] == 0 && $raw_term->weight != $weight) { + $term_weights[$raw_term->tid] = $weight; } $weight++; - $term = $tree[$weight]; }
- last update
about 1 year ago Custom Commands Failed - πͺπΈSpain plopesc Valladolid
Good catch!
That part of the code is only affected if we are loading a page that's not the first and root terms weight is not starting by 0.
Added extra tests to cover that case.
While working on this, I found out there are no tests to ensure that overview terms form submit callback behaves as expected. Should they be added here or maybe better to open a follow up issue for that?
Thanks!
- last update
about 1 year ago 30,427 pass - Status changed to RTBC
about 1 year ago 6:09pm 23 October 2023 - πΊπΈUnited States smustgrave
Failed asserting that actual size 11 matches expected size 5.
Ran new tests to make sure they failed and clearly they did.
Seems feedback has been updated.
- last update
about 1 year ago 30,435 pass - last update
about 1 year ago 30,439 pass - last update
about 1 year ago 30,457 pass - last update
about 1 year ago 30,473 pass - last update
about 1 year ago 30,484 pass - last update
about 1 year ago 30,487 pass - last update
about 1 year ago 30,487 pass - last update
about 1 year ago 30,489 pass - last update
about 1 year ago 30,513 pass - last update
about 1 year ago 30,520 pass - last update
about 1 year ago 30,531 pass - last update
about 1 year ago 30,553 pass - Status changed to Needs review
about 1 year ago 1:31am 16 November 2023 - π¬π§United Kingdom alexpott πͺπΊπ
-
+++ b/core/modules/taxonomy/tests/modules/taxonomy_test/taxonomy_test.module @@ -46,3 +46,16 @@ function taxonomy_test_form_taxonomy_term_form_alter(&$form, FormStateInterface + $value = \Drupal::state()->get(__FUNCTION__); + if (isset($value)) { + foreach ($entities as $entity) { + $value[$entity->id()] = $entity; + } + \Drupal::state()->set(__FUNCTION__, $value); + }
I don't think we should be save the term objects to state.
I think this could be
$value = \Drupal::state()->get(__FUNCTION__); // Only record loaded terms is the test has set this to an empty array. if (is_array($value)) { $value = array_merge($value, array_keys($entities)); \Drupal::state()->set(__FUNCTION__, array_unique($value)); } </codede> </li> <li> <code> +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermPagerTest.php @@ -73,4 +73,48 @@ public function testTaxonomyTermOverviewPager() { + public function testTaxonomyTermOverviewTermLoad() { + // Set limit to 3 terms per page. + $this->config('taxonomy.settings') + ->set('terms_per_page_admin', '3') + ->save(); + + $state = $this->container->get('state'); + $state->set('taxonomy_test_taxonomy_term_load', []);
The first state->set() is not required.
I've attached a patch that does the above. It also adjusted things so that we use loadMultiple() in the buildForm - this is very similar to what @catch requested in for the submit in #76
-
- π¬π§United Kingdom alexpott πͺπΊπ
Ah actually we already have a list of tids to load :) no need to built yet-another-list-of-tids...
- π¬π§United Kingdom alexpott πͺπΊπ
Updated the MR with all the changes from the issue after the last commit to it. Hiding all the files.
- Status changed to RTBC
12 months ago 3:36pm 16 November 2023 53:26 52:14 Running- last update
12 months ago 30,603 pass - last update
12 months ago 30,605 pass - last update
12 months ago 30,606 pass - last update
12 months ago 30,669 pass - last update
12 months ago 30,676 pass - last update
12 months ago 30,680 pass - last update
12 months ago 30,687 pass - last update
12 months ago 30,689 pass - last update
12 months ago 30,689 pass - last update
12 months ago 30,697 pass 38:14 34:02 Running- last update
11 months ago 30,703 pass - last update
11 months ago 30,713 pass - last update
11 months ago 30,765 pass - last update
11 months ago 30,767 pass - last update
11 months ago 25,908 pass, 1,825 fail - πΈπ°Slovakia poker10
This is not a deep performance benchmark, but I can confirm that the MR !4110 is working on few our sites with thousands of taxonomy terms. Before changes from MR were applied, there was an OOM error on the taxonomy overview page (
admin/structure/taxonomy/manage/vocabulary/overview
). After applying the changes, the page is working again.I think a more detailed benchmark could help for this to be committed (for example memory usage on that page before/after, etc..), as there is a "needs profiling" tag, but otherwise I think this works pretty well.
- π¬π§United Kingdom catch
I think it should be possible to write a performance test for this using π Allow assertions on the number of database queries run during tests RTBC - I wouldn't block it on that, this issue has existing for many years longer than that capability, but I'll open a spin-off and try to do a before/after comparison if I can and then we can commit the test coverage in its own issue.
- Status changed to Fixed
11 months ago 10:15pm 20 December 2023 - π¬π§United Kingdom catch
I opened π Performance tests for the taxonomy overview page Needs review and wrote the test, then merged the branch here in and ran the test again - and as I was writing the test coverage, realised we multiple load taxonomy terms in taxonomy get tree, which will also multiple get the cache items, and multiple set the cache items too. Given that, we can't detect the performance improvement here with PerformanceTestBase and the test run after the merged branch confirmed that - we're exchanging a massive database query for a smaller one, and nothing runs per-term.
Bit of a shame that the tests can't detect it, but also if it had detected a difference, there'd be something wrong with multiple loading, it the test would have least have probably detected the multiple load regression fixed in #84 though so worth adding anyway
Committed/pushed to 11x and cherry-picked to 10.2.x, thanks!
- ππΊHungary giorgio79
PS this issue impacts not just the taxonomy overview page, but taxonomy edit, batch update etc etc. (using Drupal 10.2.0 and php 8.1)
I have a large location based taxonomy with continents -> countries -> cities and unable to make edits, bulk update url aliases... Automatically closed - issue fixed for 2 weeks with no activity.