fix: give the remaining app config settings an empty-string default - #645
Conversation
AppConfig::getAppValue() only passes a default down to IConfig for keys listed in AppConfig::$defaults, so edit_groups, wopi_url, test_wopi_url, doc_format and menu_option returned null until an admin saved them. On PHP 8.1 and later that made every document open log an ERROR, because DocumentController::isAllowedEditor() explodes edit_groups: explode(): Passing null to parameter #2 ($string) of type string is deprecated at lib/Controller/DocumentController.php#697 The same null also reached p() on the admin settings page, and made DiscoveryService::getWopiUrl(), which declares a string return type, throw a TypeError on a server with no Collabora URL configured. No consumer branches on these values being null, with one exception that this incidentally fixes: the admin template hides the test server block when test_wopi_url === '', which could never be true while the value was null. With a test group set but no test server URL the block used to render even though js/settings-admin.js left its checkbox unchecked; it is now hidden, which is what that condition always meant to express. Fixes #644 Signed-off-by: Thomas Müller <323649642+oc-tmueller@users.noreply.github.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Reinstating the Unreleased heading makes its compare link definition live again, so point it at v4.3.1 instead of the stale v4.2.0. Signed-off-by: Thomas Müller <323649642+oc-tmueller@users.noreply.github.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
||
|
|
||
| [Unreleased]: https://github.com/owncloud/richdocuments/compare/v4.2.0...master | ||
| [Unreleased]: https://github.com/owncloud/richdocuments/compare/v4.3.1...master |
There was a problem hiding this comment.
There are a few other releases 4.2.1 4.2.2 4.3.2 that have gone missing from this section.
Maybe fix that in a follow-up PR (not directly related to this)
There was a problem hiding this comment.
Agreed, and done as a follow-up: #646.
It turned out to be a bit more than missing entries. Five headings had no definition at all —
4.2.1, 4.2.2, 4.2.3, 4.3.0, 4.3.1 (there is no 4.3.2 yet) — and on top of that two of the
existing definitions pointed at tags that were never created, so they were live 404s:
[4.0.0]→compare/v3.0.1...v4.0.0—v3.0.1was only ever tagged-beta.1/-rc.1[3.0.1]→ same missing tag, and an orphan: there is no## [3.0.1]section[2.4.0]→compare/v2.2.0...v2.4.0—v2.4.0is the oldest tag in the repo
#646 fetches every link in the block afterwards: all 15 return 200, and every section heading has
exactly one definition.
One thing worth knowing: #646 touches this same contiguous block, so the two conflict by
construction. Merging this PR first and letting me rebase #646 is the easy order.
Fixes #644.
The bug
AppConfig::getAppValue()only passes a default down toIConfigfor keys listed inAppConfig::$defaults. Five keys were missing from that list, so they returnednulluntil anadmin saved the setting:
edit_groups,wopi_url,test_wopi_url,doc_formatandmenu_option.On PHP 8.1 and later that has three visible consequences:
explode()inDocumentController::isAllowedEditor()owncloud.logon every single document open — the reported bugDiscoveryService::getWopiUrl(): stringTypeError, because astring-typed method may not return nullp()intemplates/settings-admin.php(3 places)The fix
The five missing keys get an
''default, which is how every other string setting in the class isalready handled. No other production code changes.
No consumer branches on these values being null, so the change is behaviour preserving — with one
exception it incidentally fixes: the admin template hides the test server block when
test_wopi_url === '', which could never be true while the value was null. With a test group setbut no test server URL the block used to render even though
js/settings-admin.jsleft itscheckbox unchecked; it is now hidden, which is what that condition always meant to express.
zoteroAPIPrivateKeyis deliberately left out: it is a user value and both of its readers guardwith
!empty().Verification
Run against a real ownCloud 11 install (
owncloudci/php:8.3, sqlite), reading the values throughthe real
IConfigrather than a mock, with and without the fix:tests/unit/AppConfigTest.phpgains a data-provider case per key. Itswith(..., identicalTo(''))constraint is the load-bearing part: all five cases fail with
Failed asserting that null is identical to ''when the$defaultsentries are removed.(A loose
with(..., '')does not catch this — PHPUnit compares loosely andnull == ''.)php-cs-fixerclean (0 of 45 files),phpstanlevel 5 "No errors",phanclean.Branch scope
masteronly. The missing defaults exist on4.2too, but PHP 7.4 does not surface thedeprecation there, and the 4.2.4 artifact is Collabora's to build (#643) — a commit on
4.2wouldchange the tree they were pointed at.
🤖 Generated with Claude Code