XF 2.1 v2.1.8 upgrade error: Please select a valid parent navigation entry. A navigation entry may not be a child of itself or one of its descendants.

noxa

Member
While upgrading latest v2.1.8 (Patch 2), I am facing this error.

Code:
In Entity.php line 1165:
                                                                                                                            
  [XF\PrintableException (parent_navigation_id)]                                                                             
  Please select a valid parent navigation entry. A navigation entry may not be a child of itself or one of its descendants. 
                                                                                                                            

Exception trace:
  at /home/www/html/symptome.ch/src/XF/Mvc/Entity/Entity.php:1165
 XF\Mvc\Entity\Entity->save() at /home/www/html/symptome.ch/src/XF/AddOn/DataType/Navigation.php:92
 XF\AddOn\DataType\Navigation->importAddOnData() at /home/www/html/symptome.ch/src/XF/Job/AddOnData.php:106
 XF\Job\AddOnData->run() at /home/www/html/symptome.ch/src/XF/Job/Atomic.php:38
 XF\Job\Atomic->run() at /home/www/html/symptome.ch/src/XF/Job/Manager.php:253
 XF\Job\Manager->runJobInternal() at /home/www/html/symptome.ch/src/XF/Job/Manager.php:195
 XF\Job\Manager->runJobEntry() at /home/www/html/symptome.ch/src/XF/Job/Manager.php:146
 XF\Job\Manager->runUnique() at /home/www/html/symptome.ch/src/XF/Cli/Command/JobRunnerTrait.php:30
 XF\Cli\Command\Upgrade->runJob() at /home/www/html/symptome.ch/src/XF/Cli/Command/Upgrade.php:202
 XF\Cli\Command\Upgrade->execute() at /home/www/html/symptome.ch/src/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /home/www/html/symptome.ch/src/vendor/symfony/console/Application.php:982
 Symfony\Component\Console\Application->doRunCommand() at /home/www/html/symptome.ch/src/vendor/symfony/console/Application.php:255
 Symfony\Component\Console\Application->doRun() at /home/www/html/symptome.ch/src/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at /home/www/html/symptome.ch/src/XF/Cli/Runner.php:63
 XF\Cli\Runner->run() at /home/www/html/symptome.ch/cmd.php:15

xf:upgrade [--skip-statistics]


Please help. Thanks!
 
We've had one other report of this. You can read it here:


The situation triggered there involved the user being in debug/development mode and editing core values that aren't normally editable.

Is that the case here? If so, you may need to make manual changes in the control panel to resolve this issue. (There are instructions in that thread on how to access the control panel with a pending upgrade.)
 
Thanks for the quick reply.

We are not using the forum menu which was default during first installation.

1585244964397.webp

Also, we have not touched any internal code.

1585245000085.webp

Right now we have disabled version check as instructed. We really dont know what else need to be done because there is no proper instruciton in the cosole error.
 
What version are you upgrading from? Have you installed an upgrade since you made changes to the forum navigation?

The screenshot of your navigation section does sort of confuse me, though it's hard to know if you've moved a bunch of navigation entries to another area. Otherwise, there are a bunch of missing navigation entries and I'm not sure why that's happened.

Do you think it might be possible to get a dump of your xf_navigation table? This might give me more insight into what has happened.

Saying that, the simplest way to just move beyond this error is to temporarily remove this line from src/XF/Entity/Navigation.php:
Code:
$this->error(\XF::phrase('please_select_valid_parent_navigation_entry'), 'parent_navigation_id');
I have made a change that should prevent this particular issue in the future as I think executing this code can theoretically cause an issue in some scenarios.

Once the upgrade is complete, I would restore the line.
 
It was the latest version and we are just trying to update the new patch.

Yes, we started with v2.1 and since then this is our 3rd-time upgrade. We have never faced this issue during previous upgrades.

I did change the code and ran the upgrade and it has completed without any issue. Rolled back the code again just to make sure we do not touch any core codes.

Regarding the xf_navigation table dump, do you think we can send it over PM?

Also, after the upgrade, it looks like two new menus have been added automatically which are what's new and members. These menus were not active earlier. That means the navigation table has been changed and I don't think you can find any error there.

Our suspect is, we have deleted both menus earlier and they were not present in the navigation list (admin panel area). Maybe this can be the cause. Right now we have just disabled them.

Thanks!
 
Regarding the xf_navigation table dump, do you think we can send it over PM?
Sorry, I meant to suggest it via that. Though I would need to have seen the pre-upgrade version. Saying that, I think I have a theory as to what happened:

Also, after the upgrade, it looks like two new menus have been added automatically which are what's new and members. These menus were not active earlier. That means the navigation table has been changed and I don't think you can find any error there.
Conceptually, this seems like the cause. These items really shouldn't have been deletable and I'm not sure how that happened. They should only be deletable in debug/development mode. Though as you've noted, you can disable them -- that's fine and the expected way to override them with your own options.

I haven't found any way in the UI to delete these, but I think I just found some code such that if you created your own navigation section, moved some of the "standard" navigation entries within it and then deleted your navigation section, it would cascade down deletions without checking whether you were allowed to do that. I'll need to investigate that more to figure out the appropriate behavior.

Regardless, the code change I made -- which is overall similar to the temporary change I had you made -- should prevent a situation like this from blocking an upgrade in the future.
 
Thank you for the nice feedback.

I haven't found any way in the UI to delete these, but I think I just found some code such that if you created your own navigation section, moved some of the "standard" navigation entries within it and then deleted your navigation section, it would cascade down deletions without checking whether you were allowed to do that. I'll need to investigate that more to figure out the appropriate behavior.

I am sure this is the reason. We have enabled development mode and I guess somehow they got deleted. We will be careful about these menus from now. Just wondering, what if you implement a patch where these can't be deleted, maybe disable the delete button. I mean this can be an easy mistake from the client-side.

And again, thanks for the quick responses.
 
Top Bottom