Error when adding a 'Search' block

Hi, I have recently noticed an issue on our site where I can no longer add a ‘Search’ block in any pages and received an error popup when trying to add. Below is the error message but it seems to be pointing to lots of different files so not sure where to start.

The search block was used for a number of custom templates/blocks on an older version of the website. Does anyone know where to start or experienced this issues?
Thanks
Kieran

Call to a member function getCollectionPath() on null

Details

/home/djvnbeyu32/public_html/application/blocks/search/form_setup_html.php(4): Error->null
/home/djvnbeyu32/public_html/concrete/src/Block/View/BlockView.php(361): null->include
/home/djvnbeyu32/public_html/application/blocks/search/add.php(5): Concrete\Core\Block\View\BlockView->inc
/home/djvnbeyu32/public_html/concrete/src/Block/View/BlockView.php(248): null->include
/home/djvnbeyu32/public_html/concrete/src/View/AbstractView.php(164): Concrete\Core\Block\View\BlockView->renderViewContents
/home/djvnbeyu32/public_html/concrete/views/dialogs/page/add_block.php(102): Concrete\Core\View\AbstractView->render
/home/djvnbeyu32/public_html/concrete/src/View/View.php(267): null->include
/home/djvnbeyu32/public_html/concrete/src/View/View.php(245): Concrete\Core\View\View->renderInnerContents
/home/djvnbeyu32/public_html/concrete/src/View/AbstractView.php(164): Concrete\Core\View\View->renderViewContents
/home/djvnbeyu32/public_html/concrete/src/Routing/ControllerRouteAction.php(82): Concrete\Core\View\AbstractView->render
/home/djvnbeyu32/public_html/concrete/src/Http/RouteDispatcher.php(37): Concrete\Core\Routing\ControllerRouteAction->execute
/home/djvnbeyu32/public_html/concrete/src/Http/Middleware/DispatcherDelegate.php(39): Concrete\Core\Http\RouteDispatcher->dispatch
/home/djvnbeyu32/public_html/concrete/src/Http/Middleware/MiddlewareStack.php(86): Concrete\Core\Http\Middleware\DispatcherDelegate->next
/home/djvnbeyu32/public_html/concrete/src/Http/DefaultDispatcher.php(125): Concrete\Core\Http\Middleware\MiddlewareStack->process
/home/djvnbeyu32/public_html/concrete/src/Http/DefaultDispatcher.php(58): Concrete\Core\Http\DefaultDispatcher->handleDispatch
/home/djvnbeyu32/public_html/concrete/src/Http/Middleware/DispatcherDelegate.php(39): Concrete\Core\Http\DefaultDispatcher->dispatch
/home/djvnbeyu32/public_html/concrete/src/Http/Middleware/ThumbnailMiddleware.php(76): Concrete\Core\Http\Middleware\DispatcherDelegate->next
/home/djvnbeyu32/public_html/concrete/src/Http/Middleware/MiddlewareDelegate.php(50): Concrete\Core\Http\Middleware\ThumbnailMiddleware->process
/home/djvnbeyu32/public_html/concrete/src/Http/Middleware/FrameOptionsMiddleware.php(39): Concrete\Core\Http\Middleware\MiddlewareDelegate->next
/home/djvnbeyu32/public_html/concrete/src/Http/Middleware/MiddlewareDelegate.php(50): Concrete\Core\Http\Middleware\FrameOptionsMiddleware->process
/home/djvnbeyu32/public_html/concrete/src/Http/Middleware/CookieMiddleware.php(35): Concrete\Core\Http\Middleware\MiddlewareDelegate->next
/home/djvnbeyu32/public_html/concrete/src/Http/Middleware/MiddlewareDelegate.php(50): Concrete\Core\Http\Middleware\CookieMiddleware->process
/home/djvnbeyu32/public_html/concrete/src/Http/Middleware/ApplicationMiddleware.php(29): Concrete\Core\Http\Middleware\MiddlewareDelegate->next
/home/djvnbeyu32/public_html/concrete/src/Http/Middleware/MiddlewareDelegate.php(50): Concrete\Core\Http\Middleware\ApplicationMiddleware->process
/home/djvnbeyu32/public_html/concrete/src/Http/Middleware/MiddlewareStack.php(86): Concrete\Core\Http\Middleware\MiddlewareDelegate->next
/home/djvnbeyu32/public_html/concrete/src/Http/DefaultServer.php(85): Concrete\Core\Http\Middleware\MiddlewareStack->process
/home/djvnbeyu32/public_html/concrete/src/Foundation/Runtime/Run/DefaultRunner.php(128): Concrete\Core\Http\DefaultServer->handleRequest
/home/djvnbeyu32/public_html/concrete/src/Foundation/Runtime/DefaultRuntime.php(102): Concrete\Core\Foundation\Runtime\Run\DefaultRunner->run
/home/djvnbeyu32/public_html/concrete/dispatcher.php(45): Concrete\Core\Foundation\Runtime\DefaultRuntime->run
/home/djvnbeyu32/public_html/index.php(3): null->require

Hello @Kieran0110
Let me know, version of Concrete5 CMS and PHP.
Thanks

It’s Concrete version 8.5.2 and PHP Version 7.4.32.
I’ve managed to work around the issue by renaming the search templates ‘_search’ so they are no longer being used, this allows me to add the search blocks so I’m assuming the issue was due to the templates.
Thanks

Hi @Kieran0110 - it looks like what might have happened was that maybe one of the pages that the block was referencing was deleted, and so the edit interface was trying to call getCollectionPath() on a page that didn’t exist? That would be my guess here.