Unable to remove stack

On a page we have a stack with a topic list controlling a page list.
Browsing the page is possible but the topic list has stopped working and when you have logged in to remove the faulty stack, this error is shown:
“Call to a member function getRootTreeNodeObject() on null” and you can’t remove the stack.

Any ideas on how to remove a stack when it can not be done in the GUI?

The log shows this error:
“…/web/application/blocks/topic_list/templates/flat_filter_nav/view.php:5 Call to a member function getRootTreeNodeObject() on null (0)!”

1 Like

I am assuming the page is erroring out, but you can still reach the dashboard? if you can get to the dash, you can go to “Stacks & Blocks” then “Stacks & Global areas” you will be able to delete the problematic block from there.

Your assumption is right.
But when I click on the stack to get access to “Delete” I get
“Call to a member function getRootTreeNodeObject() on null”.

flat_filter_nav/view.php:5… What’s happening on line 5 of your template? Was the topic associated with this topic list deleted by chance? Or possibly had it’s handle changed?

Also, have you tried visiting Dashboard > Full Sitemap > Include System Pages and deleting the stack from within the Stacks folder?

I didn’t have the courage to delete it from the Full Sitemap because of this apocalyptical warning:
“Warning! This is a system page. Deleting it could potentially break your site. Please proceed with caution.” :scream:

But maybe it’s safe?

On line five I have:

$node = $tree->getRootTreeNodeObject();

I don’t recall anything has been deleted and the crazy thing is that I’ve created a new identical stack with the same template – and that one works.

This may be a naïve suggestion and perhaps you’ve already tried it…

On the page where you have the stack with a topic list, is there a previous version you can roll back to that doesn’t cause the error? If so, without error it may give a bit more latitude to delete or repair the stack via the GUI.

I’m afraid this is not a viable path. The stack is used on many different pages, all of which have been updated at different times.

Naive or not – I appreciate this suggestion just as I appreciate the other attempts to help me.

Worth a shot. Is your site multilingual and have you deleted language tree that you installed as first language?

No changes has been made to the language settings. And fiddling with the language doesn’t do anything.

You can remove stack programmatically by using this code:

<?php
$s = \Stack::getByName('Your stack name');
$s->delete();
?>

but I have feeling that you will still get the same error. But try it nonetheless.

I’m not sure where to put your code?

An idea occurred to me.

Maybe commenting out the area with the non working stack in the templates and adding a new area for a working one will work.

/*				$a = new Area(’non-working-stack');
				$a->display($c);
*/                
				$a = new Area('working-stack');
				$a->display($c);
?>

This way the visitors will not get any errors visiting the site and I can delete the non working stack with your code or in the Site View without users getting errors browsing the site.

You can paste it in practically any .php file in theme folder (default.php/header_top.php - etc.) and refresh page in browser.
Remember to delete that code when you are finished.

Yeah, you can comment old area and create new one with different name, if that solves your problems. Data from old area will not be deleted anyway.

But data will be deleted from the DB running your code, I guess?

Yeah, but stack/content of stack only. Other stuff in area will be untouched (if there is any).
Do backup first, of course.