Skip to content

[Bug]: "Global Default App" setting only loads first value from config #57356

@SimJoSt

Description

@SimJoSt

⚠️ This issue respects the following points: ⚠️

Bug description

The "Global Default App" setting in the Nextcloud Administration -> Theming settings (/settings/admin/theming) does not load all entries from the config, when the page is loaded. Only the first entry is loaded.

Steps to reproduce

  1. Navigate to Nextcloud Administration -> Theming settings (/settings/admin/theming)
  2. Activate "Use custom default app" toggle
  3. Select multiple apps in select / dropdown for "Global default app"
  4. Reload page

Expected behavior

All previously selected apps should show up in the select / dropdown.

Nextcloud Server version

32

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.3

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

None

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

"defaultapp": "dashboard,activity"

List of activated Apps

Enabled:
  - activity: 5.0.0-dev.0
  - dashboard: 7.12.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

Additional info

tld;dr

Since https://github.com/nextcloud/server/releases/tag/v31.0.0 in the commit fix(NavigationManager): Skip invalid default navigation entries by @provokateurin the getDefaultEntryIds looks like this:
https://github.com/nextcloud/server/blob/v32.0.3/lib/private/NavigationManager.php#L469-L481

<?php

public function getDefaultEntryIds(bool $withFallbacks = true): array {
	$this->init();
	$storedIds = explode(',', $this->config->getSystemValueString('defaultapp', $withFallbacks ? 'dashboard,files' : ''));
	$ids = [];
	$entryIds = array_keys($this->entries);
	foreach ($storedIds as $id) {
		if (in_array($id, $entryIds, true)) {
			$ids[] = $id;
			break;
		}
	}
	return array_filter($ids);
}

The foreach contains a break, that will cancel the loop prematurely, before all entry ids have been collected to be returned:
d5e98cd#diff-df2ca3cea8da795b6a20caa98f72e0a180bcd1adbfa0b55e30e86d8e6ff261eeR475

too long, must share, because unnecessary debugging pain

Trying to find the root cause of the issue, I added a lot of var_dump() in the above code. For some reason, the function is invoked 17 times during 1 (re)load of the settings page.
And it took me many adjustments and read-throughs of the output, to realize the break caused the issue, stopping the foreach loop prematurely.

I could have seen that on the first read-through.

Invocation # 1



(empty, no variables in the function were populated)

Invocation # 2


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(1) { [0]=> string(4) "help" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(11) "foreach.id:" string(8) "activity" 
string(4) "ids:" array(0) { } 


Invocation # 3


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(2) { [0]=> string(4) "help" [1]=> string(7) "profile" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(11) "foreach.id:" string(8) "activity" 
string(4) "ids:" array(0) { } 

Invocation # 4


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(3) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(11) "foreach.id:" string(8) "activity" 
string(4) "ids:" array(0) { } 

Invocation # 5


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(4) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(11) "foreach.id:" string(8) "activity" 
string(4) "ids:" array(0) { } 

Invocation # 6


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(5) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" [4]=> string(8) "settings" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(11) "foreach.id:" string(8) "activity" 
string(4) "ids:" array(0) { } 

Invocation # 7


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(6) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" [4]=> string(8) "settings" [5]=> string(14) "admin_settings" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(11) "foreach.id:" string(8) "activity" 
string(4) "ids:" array(0) { } 

Invocation # 8


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(7) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" [4]=> string(8) "settings" [5]=> string(14) "admin_settings" [6]=> string(6) "logout" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(11) "foreach.id:" string(8) "activity" 
string(4) "ids:" array(0) { } 

Invocation # 9


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(8) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" [4]=> string(8) "settings" [5]=> string(14) "admin_settings" [6]=> string(6) "logout" [7]=> string(10) "core_users" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(11) "foreach.id:" string(8) "activity" 
string(4) "ids:" array(0) { } 

Invocation # 10


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(9) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" [4]=> string(8) "settings" [5]=> string(14) "admin_settings" [6]=> string(6) "logout" [7]=> string(10) "core_users" [8]=> string(8) "activity" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(11) "foreach.id:" string(8) "activity" 
string(12) "foreach.ids:" array(1) { [0]=> string(8) "activity" } 
string(4) "ids:" array(1) { [0]=> string(8) "activity" } 

Invocation # 11


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(10) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" [4]=> string(8) "settings" [5]=> string(14) "admin_settings" [6]=> string(6) "logout" [7]=> string(10) "core_users" [8]=> string(8) "activity" [9]=> string(9) "dashboard" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(12) "foreach.ids:" array(1) { [0]=> string(9) "dashboard" } 
string(4) "ids:" array(1) { [0]=> string(9) "dashboard" } 

Invocation # 12


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(11) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" [4]=> string(8) "settings" [5]=> string(14) "admin_settings" [6]=> string(6) "logout" [7]=> string(10) "core_users" [8]=> string(8) "activity" [9]=> string(9) "dashboard" [10]=> string(5) "files" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(12) "foreach.ids:" array(1) { [0]=> string(9) "dashboard" } 
string(4) "ids:" array(1) { [0]=> string(9) "dashboard" } 

Invocation # 13


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(12) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" [4]=> string(8) "settings" [5]=> string(14) "admin_settings" [6]=> string(6) "logout" [7]=> string(10) "core_users" [8]=> string(8) "activity" [9]=> string(9) "dashboard" [10]=> string(5) "files" [11]=> string(20) "firstrunwizard_about" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(12) "foreach.ids:" array(1) { [0]=> string(9) "dashboard" } 
string(4) "ids:" array(1) { [0]=> string(9) "dashboard" } 

Invocation # 14


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(13) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" [4]=> string(8) "settings" [5]=> string(14) "admin_settings" [6]=> string(6) "logout" [7]=> string(10) "core_users" [8]=> string(8) "activity" [9]=> string(9) "dashboard" [10]=> string(5) "files" [11]=> string(20) "firstrunwizard_about" [12]=> string(6) "photos" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(12) "foreach.ids:" array(1) { [0]=> string(9) "dashboard" } 
string(4) "ids:" array(1) { [0]=> string(9) "dashboard" } 

Invocation # 15


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(14) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" [4]=> string(8) "settings" [5]=> string(14) "admin_settings" [6]=> string(6) "logout" [7]=> string(10) "core_users" [8]=> string(8) "activity" [9]=> string(9) "dashboard" [10]=> string(5) "files" [11]=> string(20) "firstrunwizard_about" [12]=> string(6) "photos" [13]=> string(13) "thesearchpage" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(12) "foreach.ids:" array(1) { [0]=> string(9) "dashboard" } 
string(4) "ids:" array(1) { [0]=> string(9) "dashboard" } 

Invocation # 16


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(15) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" [4]=> string(8) "settings" [5]=> string(14) "admin_settings" [6]=> string(6) "logout" [7]=> string(10) "core_users" [8]=> string(8) "activity" [9]=> string(9) "dashboard" [10]=> string(5) "files" [11]=> string(20) "firstrunwizard_about" [12]=> string(6) "photos" [13]=> string(13) "thesearchpage" [14]=> string(22) "user_status-menu-entry" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(12) "foreach.ids:" array(1) { [0]=> string(9) "dashboard" } 
string(4) "ids:" array(1) { [0]=> string(9) "dashboard" } 
string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(15) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" [4]=> string(8) "settings" [5]=> string(14) "admin_settings" [6]=> string(6) "logout" [7]=> string(10) "core_users" [8]=> string(8) "activity" [9]=> string(9) "dashboard" [10]=> string(5) "files" [11]=> string(20) "firstrunwizard_about" [12]=> string(6) "photos" [13]=> string(13) "thesearchpage" [14]=> string(22) "user_status-menu-entry" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(12) "foreach.ids:" array(1) { [0]=> string(9) "dashboard" } 
string(4) "ids:" array(1) { [0]=> string(9) "dashboard" } 

Invocation # 17


string(10) "storedIds:" array(2) { [0]=> string(9) "dashboard" [1]=> string(8) "activity" } 
string(9) "entryIds:" array(15) { [0]=> string(4) "help" [1]=> string(7) "profile" [2]=> string(22) "accessibility_settings" [3]=> string(9) "core_apps" [4]=> string(8) "settings" [5]=> string(14) "admin_settings" [6]=> string(6) "logout" [7]=> string(10) "core_users" [8]=> string(8) "activity" [9]=> string(9) "dashboard" [10]=> string(5) "files" [11]=> string(20) "firstrunwizard_about" [12]=> string(6) "photos" [13]=> string(13) "thesearchpage" [14]=> string(22) "user_status-menu-entry" } 
string(11) "foreach.id:" string(9) "dashboard" 
string(12) "foreach.ids:" array(1) { [0]=> string(9) "dashboard" } 
string(4) "ids:" array(1) { [0]=> string(9) "dashboard" }
```

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions