Closed (fixed)
Project:
TOC API
Version:
2.0.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Apr 2025 at 10:47 UTC
Updated:
4 Aug 2025 at 23:58 UTC
Jump to comment: Most recent
It seems that the new toc_api 2.x version has an issue with Layout Builder, as the getCurrentToc() method returns a null value.
TypeError: Drupal\toc_api\Plugin\Block\TocBlockBase::getCurrentToc(): Return value must be of type Drupal\toc_api\TocInterface, null returned in Drupal\toc_api\Plugin\Block\TocBlockBase->getCurrentToc()
I also noticed that the getCurrentNode() function checks the route name, but it doesn't account for Layout Builder paths.
I've marked this as a major priority because it breaks the Layout Builder experience.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
joseph.olstadI will review merge requests and or related patches.
Comment #3
joseph.olstadPlease apply the upstream patch!
Comment #4
liam morlandWhat is the patch that needs to be applied?
Comment #5
joseph.olstadPatch for the toc_filter module: #3518549-13: Make TocFilterBlock::blockAccess() return type be compatible with parent
OR
For the toc_filter module: https://git.drupalcode.org/project/toc_filter/-/merge_requests/14.diff
Comment #6
liam morlandUnless I am misunderstanding something, this should be closed as duplicate of #3518549: Make TocFilterBlock::blockAccess() return type be compatible with parent.
Comment #7
joseph.olstadWe should close this when the upstream toc_filter patch is committed/resolved/fixed.
Comment #8
joseph.olstadComment #9
vladimirausThanks all. Committed. 🍻
Comment #10
joseph.olstadThank you!
Comment #12
phma commentedI updated to the latest version of toc_filter, and I'm still getting the exact same error. Am I missing something?
Comment #13
joseph.olstaddouble check your composer.lock for
drupal/toc_filter:2.4drush pml | grep tocrebuild cache, and sometimes need to restart php service if you've got greedy opcode cache / apcu.
Comment #14
phma commentedCorrect me if I'm wrong, but I this seems to be a separate issue to #3518549: Make TocFilterBlock::blockAccess() return type be compatible with parent
getTocinTocManager.phpcan return NULL. But this case isn't handled properly inTocBlockBase.php.I can create a patch, but should we reopen this issue, as it isn't really fixed in my opinion?
Comment #15
phma commentedIt duplicated my comment, when I tried to edit it, sorry.
Comment #16
joseph.olstadas per comment #14
Comment #17
fjgarlin commentedI agree that this is not the same as #3518549: Make TocFilterBlock::blockAccess() return type be compatible with parent.
This issue belongs to this queue and. can be fixed as suggested in #14.
Comment #19
phma commentedComment #20
joseph.olstadComment #21
joseph.olstadComment #22
joseph.olstadhttps://www.drupal.org/project/toc_api/releases/2.0.1-rc1
Comment #24
joseph.olstadPlease upgrade to 2.0.1-rc1 and let me know how it works out for you. I won't tag 2.0.1 until I get at least some statistics on usage or some kind of feedback.