Wiki toc macro now broken on pages it used to work on that have not changed

Issue #5520 duplicate
Anonymous created an issue

Gives an error "Wiki macro error: expected string or buffer" when used to show local page contents. For example, this page was posted in the "how to use the toc macro" comments long ago but now the example for local page contents is broken:

I use <<toc 2>> on my pages, none of the pages changed but recently they all start with that error instead of showing the toc.