Closed (fixed)
Project:
Drupal core
Version:
8.9.x-dev
Component:
book.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
30 Oct 2018 at 20:06 UTC
Updated:
29 Jul 2020 at 13:02 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
benjifisherThe only reason the node is loaded is in order to get
$node->urlInfo(). In my limited testing,"entity:node/$nid"works just as well. (This is passed toUrl::fromUri().) The attached patch makes this little change.Comment #3
benjifisherOriginally, I counted using
array_walk_recursive()on the tree of links returned bybookTreeAllData(). I came up with a much larger number, since each link it itself a structured array. I came up with 3,600 by counting the number of<a>elements in the HTML markup for the navigation.I am not sure of my analysis. I originally thought that
Node::loadMultiple()was called indirectly bybookTreeAllData(). That may be correct, but now I cannot find such a call to confirm what I said. I may have been looking at a call toBookOutlineStorageI::loadMultiple().I am pretty sure that I need both the optimization in this issue and some additional caching in order to improve my page-load times. I tried using each by itself and did not find any improvement.
Comment #5
piotrkonefal commentedHere is the rerolled version for 8.7.x
Comment #7
joachim commentedComment #8
alexpottIt'd be by great if someone can point to where these links are tested as the change seems sensible but in order to commit a change like this I'd need to prove we have existing test coverage.
Comment #9
benjifisherThose links are tested in
Drupal\Tests\book\Functional\BookTest::testBook(). It is a little hard to follow, especially since that test uses methods fromDrupal\Tests\book\Functional\BookTestTrait. So why not hack the patch and let the testbot show us where the links are tested?Comment #11
benjifisherI am setting the status back to RTBC and re-uploading the patch from #3 so that the testbot does not get confused.
Unfortunately, the testbot seems to be truncating the error messages :-(. Here is what I get when I run
testBook()locally:Comment #12
alexpottThis looks like a really nice fix.
Committed and pushed 702b8f1aa8 to 9.0.x and 0537629fa4 to 8.9.x. Thanks!
Comment #15
benjifisher@joachim, @alexpott:
Thanks for taking a look at this issue! It is nice to know that, even during the mad dash to get 9.0 ready for beta, we can still get little fixes like this one into the codebase.
Comment #16
wim leersVery nice perf win!
Comment #18
nicrodgersI've spotted a problem with this change. I've created https://www.drupal.org/project/drupal/issues/3155869 and would appreciate your thoughts on the best way to proceed.
Comment #19
lpeabody commentedI think this change probably broke any site using the book_tree template.
EDIT: *Customized book_tree template where item.url is not passed into the link function. We generally don't end up using the Twig link function a lot because frontend devs usually like to markup anchor elements in their own prototypes before we integrate them in Drupal templates. In several usages of book-tree.html.twig, we just pass item.url in as a parameter to separate Twig templates that render variations of an anchor element. Having item.url not be a Url object is a departure to how that variable has traditionally been treated.
Comment #20
lpeabody commentedI opened https://www.drupal.org/project/drupal/issues/3162181 as a task for updating the now out-dated documentation in the various book-tree.html.twig files in core.Issue was redundant since https://www.drupal.org/project/drupal/issues/3155869 does account for the possibility of just having to update the Twig documentation, as opposed to just reverting item.url back to a Url object.