To reproduce:

1. Enable the Book module and the Help module.
2. Logged in as user 1 (or a user with book and node admin permission) Go to Create Content. Create a book node, then click "Add child page", and add a child. The book seems to be OK so far - you can see the book and its parent.
3. From either page, click "Outline". Help at the top of the page says "The outline feature allows you to include pages in the Book hierarchy, as well as move them within the hierarchy or to reorder an entire book.". "Book hierarchy" is a link to the route book.render, which is at path /book. "reorder an entire book" is a link to the route book.admin, which is at path /admin/structure/book.
4. Click the /book link. You get an error page:

Notice: Undefined index: href in Drupal\book\Controller\BookController->bookRender() (line 108 of core/modules/book/lib/Drupal/book/Controller/BookController.php).
Notice: Undefined index: options in Drupal\book\Controller\BookController->bookRender() (line 108 of core/modules/book/lib/Drupal/book/Controller/BookController.php).
Recoverable fatal error: Argument 3 passed to l() must be of the type array, null given, called in (.....)core/modules/book/lib/Drupal/book/Controller/BookController.php on line 108 and defined in l() (line 1025 of core/includes/common.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

msmithcti’s picture

Assigned: Unassigned » msmithcti

I'll give this a go.

msmithcti’s picture

Status: Active » Needs review
FileSize
1.39 KB

Fixed the arguments passed to l() in BookController::bookRender(). Looking at BookManager::loadBooks() it will never return link options, so I'm just not passing them in. Provided tests for this page as coverage was lacking.

Status: Needs review » Needs work

The last submitted patch, 2: d8-route-book-render-2250325-2.patch, failed testing.

jhodgdon’s picture

Looks like a legitimate test failure...

azinck’s picture

Assigned: msmithcti » azinck
Status: Needs work » Needs review
FileSize
1.43 KB

Re-rolled to accommodate PSR-4 and made some minor tweaks to the test.

jhodgdon’s picture

Status: Needs review » Needs work

In manual testing that led to me filing this bug, I don't think I saw the errors until I had added a child page to the book.

In any case, when adding a test for a book, please also make a "test-only" patch (without the bug fix code change) and upload it separately, so that we can verify that the test (without the code patch) fails in such a way that it is actually testing the reported bug.

Thanks!

azinck’s picture

Status: Needs work » Needs review
FileSize
827 bytes

No problem. Here's the test only.

Status: Needs review » Needs work

The last submitted patch, 7: d8-route-book-render-test-only-2250325-7.patch, failed testing.

azinck’s picture

azinck’s picture

Status: Needs work » Needs review
jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
1.43 KB

Excellent! The test-only patch failed exactly like my issue report.

I'm re-uploading the patch in #5, which is RTBC.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Great work!

Committed and pushed to 8.x. Thanks!

  • Commit d4ac818 on 8.x by webchick:
    Issue #2250325 by jhodgdon, azinck, splatio: Fixed Route book.render (...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.