Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Additionally, the community document server only supports running on x86-64 Linu
<screenshot>https://raw.githubusercontent.com/nextcloud/documentserver_community/master/screenshots/main.png</screenshot>
<screenshot>https://raw.githubusercontent.com/nextcloud/documentserver_community/master/screenshots/new.png</screenshot>
<dependencies>
<nextcloud min-version="21" max-version="33"/>
<nextcloud min-version="21" max-version="34"/>
</dependencies>

<background-jobs>
Expand Down
33 changes: 31 additions & 2 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -75,14 +75,43 @@ 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
);
});
}

/**
* 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')) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Document/ConverterBinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Document/DocumentStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions lib/DocumentConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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";
Expand Down