Fix boot failure on Nextcloud 34, support onlyoffice connector >= 10.1, and fix PHP 8.4 nullable deprecations#376
Conversation
PHP 8.4 deprecates implicitly marking parameters as nullable (Type $param = null). Make the nullable type explicit (?Type) for the $password parameters in DocumentConverter, ConverterBinary and DocumentStore. Signed-off-by: NSO73 <108399823+NSO73@users.noreply.github.com>
The onlyoffice connector 10.1 expanded AppConfig::__construct from (string, IConfig, LoggerInterface, ICacheFactory) to (string, IAppConfig, IConfig, IUserConfig, LoggerInterface, ICacheFactory), which made documentserver_community fail to boot with a TypeError. Detect the constructor arity at runtime and pass the matching arguments, keeping compatibility with older connector versions (<= 10.0) and the Nextcloud versions that ship them. Signed-off-by: NSO73 <108399823+NSO73@users.noreply.github.com>
7315b9b to
335ce64
Compare
|
I have this exact issue too. The PR looks like a sensible fix. |
|
Note the fix on line 96 of my file below, this allows docserver to work on NC34. |
|
Thanks @sjs6776 (and @defame-flagstick) — I've folded the getConfig() fix into the PR (commit c230ddf): Heads-up: I've since migrated to a native EuroOffice setup, so I won't be actively testing/maintaining this on my side anymore. I'm leaving the PR open in case it's useful to others and a maintainer wants to pick it up. |
Resolve IConfig through the DI container instead of the deprecated \OC::$server->getConfig(), which is gone on NC34. Same service, no behaviour change. Credit to sjs6776 and defame-flagstick. Signed-off-by: NSO73 <108399823+NSO73@users.noreply.github.com>
c230ddf to
fbc8112
Compare
|
This PR is also required for Nextcloud 34, not only for connector >= 10.1 — that might be worth reflecting in the title, since it's easy to miss. On NC 34, The visible result is HTTP 500 on I ran into both on a production instance:
To confirm the diagnosis I applied the equivalent change by hand ( One gap this PR doesn't cover: |
|
Update: I've now verified the editor itself on the same instance (Nextcloud 34.0.1, PHP 8.3.31, onlyoffice connector 10.1.2) — opening and editing Still accurate: I'm running the equivalent fix applied by hand, not this branch verbatim. |
Bump max-version to 34 now that the boot failures on NC 34 (getConfig() removal, AppConfig signature change) are fixed. Signed-off-by: NSO73 <108399823+NSO73@users.noreply.github.com>
af17bf0 to
9912f1a
Compare
|
Thanks @blueforce, both of your points are addressed:
I've also rewritten the PR description so everything is in one place: the I left As mentioned above, I'm no longer running this setup myself, so I won't be doing further testing on my side. Everything known is now in the description; happy for a maintainer to take it from here or push to the branch. |
|
Update: I've now tested this branch verbatim on a production instance — the five files from Environment
What I verified
The only thing I saw that isn't a 200: a 404 on My earlier caveat ("equivalent fix by hand, not this branch verbatim") no longer applies — this is the branch itself. Without it the app doesn't boot at all on NC 34, so from my side this is ready to merge. |
What
Four related fixes that let
documentserver_communityboot and run on Nextcloud 34 and with the current ONLYOFFICE connector on recent PHP.On Nextcloud 34 the app currently fails to boot on every request, so this is not only a connector >= 10.1 issue.
1. Fix boot failure on Nextcloud 34 (
getConfig()removed)OC\Server::getConfig()no longer exists on NC 34, so thenew AppConfig('onlyoffice', \OC::$server->getConfig(), ...)calls inApplication.phpbreak the app on every request:Visible symptoms: HTTP 500 on
/apps/documentserver_community/healthcheck, and "Error when trying to connect" on the admin page.IConfigis now resolved through the DI container (\OC::$server->get(\OCP\IConfig::class)) instead of the removed accessor. Same service, no behaviour change.Credit to @sjs6776 and @defame-flagstick, who diagnosed this and posted the fix in the comments.
2. Support ONLYOFFICE connector >= 10.1 (AppConfig constructor change)
Once the boot failure above is fixed, the next blocker is the connector's constructor signature.
OCA\Onlyoffice\AppConfig::__constructchanged in 10.1 fromto
With the old 4-argument call the app no longer boots:
A new
buildAppConfig()helper detects the constructor arity at runtime via reflection and passes the matching arguments, so it keeps working with both the old (<= 10.0) and the new (>= 10.1) connector, and with the Nextcloud versions that ship them (OCP\Config\IUserConfigonly exists on the newer ones). The two duplicated inline constructions are replaced by calls to this helper.3. PHP 8.4 — explicit nullable parameter types
PHP 8.4 deprecates implicitly nullable parameters (
Type $x = null). Made the nullable explicit (?Type) for the$passwordparameters inDocumentConverter,ConverterBinaryandDocumentStore. No behaviour change; removes the deprecation warnings logged on every document conversion.4. Allow installation on Nextcloud 34
appinfo/info.xmlstill declaredmax-version="33", so even with the fixes above the app would not be offered on NC 34. Bumped tomax-version="34".Changed files
lib/AppInfo/Application.phpbuildAppConfig()helper: DI-resolvedIConfig+ connector arity detectionlib/DocumentConverter.php?Typeon$passwordlib/Document/ConverterBinary.php?Typeon$passwordlib/Document/DocumentStore.php?Typeon$passwordappinfo/info.xmlmax-version33 → 34Testing
Verified on Nextcloud 33.0.5 / PHP 8.4 / connector 10.1.0: the app boots,
/healthcheckreturns 200, documents open and convert.Independently reported on Nextcloud 34.0.1 / PHP 8.3.31 / connector 10.1.2 / documentserver_community 0.2.4 by @blueforce: the app boots cleanly,
/healthcheckreturnstrue, the boot errors disappear from the log, and opening/editing.docxand.xlsxworks with no errors. To be precise about scope: that confirmation was obtained with the equivalent fix applied by hand (\OC::$server->get(\OCP\IConfig::class)plus the 6-argument constructor), not with this branch checked out verbatim.Note
I have since migrated to a different setup and won't be actively testing or maintaining this going forward. The PR is left open in case it is useful; happy for a maintainer to take it over or push to the branch.