diff --git a/appinfo/info.xml b/appinfo/info.xml
index d3fceee..ccbce02 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -31,7 +31,7 @@ Additionally, the community document server only supports running on x86-64 Linu
https://raw.githubusercontent.com/nextcloud/documentserver_community/master/screenshots/main.png
https://raw.githubusercontent.com/nextcloud/documentserver_community/master/screenshots/new.png
-
+
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index f0a6769..f78c51c 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -62,7 +62,7 @@ public function register(IRegistrationContext $context): void {
$context->registerService(URLDecoder::class, function (IAppContainer $container) {
$server = $container->getServer();
- $appConfig = new AppConfig('onlyoffice', \OC::$server->getConfig(), \OCP\Log\logger('onlyoffice'), \OC::$server->get(ICacheFactory::class));
+ $appConfig = $this->buildAppConfig();
$crypto = new Crypt($appConfig);
return new URLDecoder(
@@ -75,7 +75,7 @@ public function register(IRegistrationContext $context): void {
$context->registerService(AutoConfig::class, function (IAppContainer $container) {
$server = $container->getServer();
- $appConfig = new AppConfig('onlyoffice', \OC::$server->getConfig(), \OCP\Log\logger('onlyoffice'), \OC::$server->get(ICacheFactory::class));
+ $appConfig = $this->buildAppConfig();
return new AutoConfig(
$server->get(IURLGenerator::class),
$appConfig
@@ -83,6 +83,35 @@ public function register(IRegistrationContext $context): void {
});
}
+ /**
+ * Build an onlyoffice AppConfig instance regardless of the connector version.
+ *
+ * The onlyoffice connector changed AppConfig's constructor signature over
+ * time: up to 10.0 it was (string, IConfig, LoggerInterface, ICacheFactory);
+ * from 10.1 it became (string, IAppConfig, IConfig, IUserConfig,
+ * LoggerInterface, ICacheFactory). Detect the arity and pass accordingly so
+ * this app keeps booting across connector and Nextcloud versions.
+ */
+ private function buildAppConfig(): AppConfig {
+ $config = \OC::$server->get(\OCP\IConfig::class);
+ $logger = \OCP\Log\logger('onlyoffice');
+ $cacheFactory = \OC::$server->get(ICacheFactory::class);
+
+ $paramCount = (new \ReflectionMethod(AppConfig::class, '__construct'))->getNumberOfParameters();
+ if ($paramCount >= 6) {
+ return new AppConfig(
+ 'onlyoffice',
+ \OC::$server->get(\OCP\IAppConfig::class),
+ $config,
+ \OC::$server->get(\OCP\Config\IUserConfig::class),
+ $logger,
+ $cacheFactory
+ );
+ }
+
+ return new AppConfig('onlyoffice', $config, $logger, $cacheFactory);
+ }
+
public function boot(IBootContext $context): void {
$context->injectFn(function (IAppManager $appManager) {
if ($appManager->isEnabledForUser('onlyoffice')) {
diff --git a/lib/Document/ConverterBinary.php b/lib/Document/ConverterBinary.php
index 47a44d2..964c5b3 100644
--- a/lib/Document/ConverterBinary.php
+++ b/lib/Document/ConverterBinary.php
@@ -34,7 +34,7 @@ public function __construct(LoggerInterface $logger) {
$this->logger = $logger;
}
- public function run(string $param, string $password = null): string {
+ public function run(string $param, ?string $password = null): string {
if (!is_executable(self::BINARY_DIRECTORY . '/x2t')) {
@chmod(self::BINARY_DIRECTORY . '/x2t', 0755);
}
diff --git a/lib/Document/DocumentStore.php b/lib/Document/DocumentStore.php
index b5905ef..c0c1911 100644
--- a/lib/Document/DocumentStore.php
+++ b/lib/Document/DocumentStore.php
@@ -73,7 +73,7 @@ private function getDocumentFolder(int $documentId): ISimpleFolder {
}
}
- public function getDocumentForEditor(int $documentId, File $sourceFile, string $sourceFormat, string $password = null): ISimpleFile {
+ public function getDocumentForEditor(int $documentId, File $sourceFile, string $sourceFormat, ?string $password = null): ISimpleFile {
$docFolder = $this->getDocumentFolder($documentId);
try {
return $docFolder->getFile('Editor.bin');
diff --git a/lib/DocumentConverter.php b/lib/DocumentConverter.php
index babed28..e9b7d8e 100644
--- a/lib/DocumentConverter.php
+++ b/lib/DocumentConverter.php
@@ -42,7 +42,7 @@ public function __construct(ITempManager $tempManager, ConverterBinary $converte
$this->converter = $converterBinary;
}
- public function getEditorBinary($source, string $sourceExtension, string $targetFolder, string $password = null) {
+ public function getEditorBinary($source, string $sourceExtension, string $targetFolder, ?string $password = null) {
$sourceFile = $this->tempManager->getTemporaryFile(".$sourceExtension");
file_put_contents($sourceFile, $source);
@@ -106,14 +106,14 @@ private function rmdirr($path) {
}
- public function convertFiles(string $from, string $to, int $targetFormat = DocumentFormat::AVS_OFFICESTUDIO_FILE_CANVAS, string $password = null) {
+ public function convertFiles(string $from, string $to, int $targetFormat = DocumentFormat::AVS_OFFICESTUDIO_FILE_CANVAS, ?string $password = null) {
$command = new ConvertCommand($from, $to);
$command->setTargetFormat($targetFormat);
$this->runCommand($command, $password);
}
- public function runCommand(ConvertCommand $command, string $password = null) {
+ public function runCommand(ConvertCommand $command, ?string $password = null) {
$xmlFile = $this->tempManager->getTemporaryFile('.xml');
$xmlWriter = new Writer();
$xmlWriter->namespaceMap["http://www.w3.org/2001/XMLSchema-instance"] = "xsi";