[GH-ISSUE #372] reopening XLSX files "The file version has changed.." error with data loss #192

Closed
opened 2026-02-26 10:30:48 +03:00 by kerem · 5 comments
Owner

Originally created by @zilexa on GitHub (Aug 9, 2021).
Original GitHub issue: https://github.com/ONLYOFFICE/Docker-DocumentServer/issues/372

Do you want to request a feature or report a bug?
Bug.

What is the current behavior?
After creating a new XLSX file and editing it, also when editing an existing XLSX files, after you close it and reopen it, the following error appears and the document is empty (!).
This only happens with XLSX files since I recreated the container with the latest image. Unfortunately, I am not sure which version I used before, I believe a version from February or March 2021:
0fc969fce32dbaea858e9fc6230fa98b
This bug leads to loss of data, there is no way to get the content back.

log:

Creating new PostgreSQL cluster 12/main ...
/usr/lib/postgresql/12/bin/initdb -D /var/lib/postgresql/12/main --auth-local peer --auth-host md5
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/12/main ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

    pg_ctlcluster 12 main start

Ver Cluster Port Status Owner    Data directory              Log file
12  main    5432 down   postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
 * Starting PostgreSQL 12 database server        
[ OK ]
 * Starting RabbitMQ Messaging Server rabbitmq-server        
[ OK ]
CREATE DATABASE
CREATE ROLE
GRANT
psql:/var/www/onlyoffice/documentserver/server/schema/postgresql/removetbl.sql:4: NOTICE:  table "doc_callbacks" does not exist skipping
psql:/var/www/onlyoffice/documentserver/server/schema/postgresql/removetbl.sql:9: NOTICE:  function merge_db(pg_catalog.varcharint2int8pg_catalog.timestamppg_catalog.varcharint8int8) does not exist skipping
psql:/var/www/onlyoffice/documentserver/server/schema/postgresql/removetbl.sql:10: NOTICE:  function merge_db(pg_catalog.varcharint2int4pg_catalog.timestamppg_catalog.varcharint4int4) does not exist skipping
Starting supervisor: supervisord.
 * Starting periodic command scheduler cron        
[ OK ]
 * Starting nginx nginx        
[ OK ]
Generating AllFonts.js please wait...Done
Generating presentation themes please wait...Done
ds:docservice: stopped
ds:docservice: started
ds:converter: stopped
ds:converter: started
 * Reloading nginx configuration nginx        
[ OK ]
==> /var/log/onlyoffice/documentserver/converter/err.log <==

==> /var/log/onlyoffice/documentserver/converter/out.log <==
[2021-08-09T07:12:05.203] [WARN] nodeJS - update cluster with 1 workers
[2021-08-09T07:12:05.210] [WARN] nodeJS - worker 1056 started.
[2021-08-09T07:12:05.212] [WARN] nodeJS - update cluster with 1 workers
[2021-08-09T07:12:45.390] [WARN] nodeJS - update cluster with 1 workers
[2021-08-09T07:12:45.396] [WARN] nodeJS - worker 1161 started.
[2021-08-09T07:12:45.398] [WARN] nodeJS - update cluster with 1 workers

==> /var/log/onlyoffice/documentserver/docservice/err.log <==

==> /var/log/onlyoffice/documentserver/docservice/out.log <==
[2021-08-09T07:12:05.655] [WARN] nodeJS - Express server starting...
[2021-08-09T07:12:05.657] [WARN] nodeJS - Failed to subscribe to plugin folder updates. When changing the list of plugins you must restart the server. https://nodejs.org/docs/latest/api/fs.html#fs_availability
[2021-08-09T07:12:05.702] [WARN] nodeJS - Express server listening on port 8000 in production-linux mode. Version: 6.3.1. Build: 32
[2021-08-09T07:12:44.112] [WARN] nodeJS - Express server starting...
[2021-08-09T07:12:44.113] [WARN] nodeJS - Failed to subscribe to plugin folder updates. When changing the list of plugins you must restart the server. https://nodejs.org/docs/latest/api/fs.html#fs_availability
[2021-08-09T07:12:44.135] [WARN] nodeJS - Express server listening on port 8000 in production-linux mode. Version: 6.3.1. Build: 32

==> /var/log/onlyoffice/documentserver/metrics/err.log <==

==> /var/log/onlyoffice/documentserver/metrics/out.log <==
9 Aug 07:12:05 - [998] reading config file: ./config/config.js
9 Aug 07:12:05 - server is up INFO

==> /var/log/onlyoffice/documentserver/nginx.error.log <==

==> /var/log/onlyoffice/documentserver/converter/out.log <==
[2021-08-09T07:14:57.878] [ERROR] nodeJS - stdout (id=23--1628493219_1268):
[2021-08-09T07:14:57.878] [ERROR] nodeJS - stderr (id=23--1628493219_1268):Uncaught TypeError: Cannot read property 'Kxa' of null
DoctRenderer:<result><error index="-2" /></result>

[2021-08-09T07:14:57.879] [ERROR] nodeJS - ExitCode (code=86;signal=null;error:-86;id=23--1628493219_1268)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Simple:

  1. Edit (open) an XLSX file in OnlyOffice DocumentServer with AutoSave on (or off doesn't matter).
  2. Add some text.
  3. Close the file.
  4. Wait 20 seconds.
  5. Open the file again in OnlyOffice DocumentServer.
  6. Notice the error.

Note I use FileRun, a PHP based filemanager (a simple NextCloud alternative):
https://filerun.com/
OnlyOffice is supported as plugin. The install base of FileRun contains the following within the plugin folder of OnlyOffice:

  • blanks (folder containing empty document files (templates/defaults))
  • JWT (folder containing a few files probably to support JWT secret (which I have to enter in FileRun UI Settings).
  • app.php (see first comment below)
  • display.php (below)
  • index.html (0 bytes file)

display.php:

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title><?php echo \S::safeHTML(\S::forHTML($this->data['fileName']));?></title>
	<style>
		body {
			border: 0;
			margin: 0;
			padding: 0;
			overflow:hidden;
		}
	</style>
</head>

<body>
<div id="placeholder"></div>
<script type="text/javascript" src="<?php echo gluePath(self::getSetting('serverURL'), '/web-apps/apps/api/documents/api.js');?>"></script>
<script>
	var docEditor = new DocsAPI.DocEditor("placeholder", <?php echo json_encode($opts);?>);
</script>
</body>
</html>

I believe the issue might be within the app.php file, the newer versions of OnlyOffice DocumentServer probably require some change in the way it communicates with the filemanager.

I hope, I really hope someone is willing to have a look and verify the app.php file is still correct.
It seems the devteam of FileRun has moved a bit closer to LibreOffice server edition and not that interested in fixing this issue. I really hope I can get it fixed, because I am a BIG OnlyOffice fan.

What is the expected behavior?
No error, no loss of content.

Did this work in previous versions of DocumentServer?
Yes.

DocumentServer Docker tag:
Latest.

Host Operating System:
Ubuntu 21.04

Originally created by @zilexa on GitHub (Aug 9, 2021). Original GitHub issue: https://github.com/ONLYOFFICE/Docker-DocumentServer/issues/372 **Do you want to request a *feature* or report a *bug*?** Bug. **What is the current behavior?** After creating a new XLSX file and editing it, also when editing an existing XLSX files, after you close it and reopen it, the following error appears and the document is empty (!). This only happens with XLSX files since I recreated the container with the latest image. Unfortunately, I am not sure which version I used before, I believe a version from February or March 2021: ![0fc969fce32dbaea858e9fc6230fa98b](https://user-images.githubusercontent.com/3430004/128672041-81937521-94ee-4ae2-a6c8-7fca3b3b7e72.png) This bug leads to loss of data, there is no way to get the content back. log: ``` Creating new PostgreSQL cluster 12/main ... /usr/lib/postgresql/12/bin/initdb -D /var/lib/postgresql/12/main --auth-local peer --auth-host md5 The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "en_US.UTF-8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english". Data page checksums are disabled. fixing permissions on existing directory /var/lib/postgresql/12/main ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default time zone ... Etc/UTC creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok Success. You can now start the database server using: pg_ctlcluster 12 main start Ver Cluster Port Status Owner Data directory Log file 12 main 5432 down postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log * Starting PostgreSQL 12 database server [ OK ] * Starting RabbitMQ Messaging Server rabbitmq-server [ OK ] CREATE DATABASE CREATE ROLE GRANT psql:/var/www/onlyoffice/documentserver/server/schema/postgresql/removetbl.sql:4: NOTICE: table "doc_callbacks" does not exist skipping psql:/var/www/onlyoffice/documentserver/server/schema/postgresql/removetbl.sql:9: NOTICE: function merge_db(pg_catalog.varcharint2int8pg_catalog.timestamppg_catalog.varcharint8int8) does not exist skipping psql:/var/www/onlyoffice/documentserver/server/schema/postgresql/removetbl.sql:10: NOTICE: function merge_db(pg_catalog.varcharint2int4pg_catalog.timestamppg_catalog.varcharint4int4) does not exist skipping Starting supervisor: supervisord. * Starting periodic command scheduler cron [ OK ] * Starting nginx nginx [ OK ] Generating AllFonts.js please wait...Done Generating presentation themes please wait...Done ds:docservice: stopped ds:docservice: started ds:converter: stopped ds:converter: started * Reloading nginx configuration nginx [ OK ] ==> /var/log/onlyoffice/documentserver/converter/err.log <== ==> /var/log/onlyoffice/documentserver/converter/out.log <== [2021-08-09T07:12:05.203] [WARN] nodeJS - update cluster with 1 workers [2021-08-09T07:12:05.210] [WARN] nodeJS - worker 1056 started. [2021-08-09T07:12:05.212] [WARN] nodeJS - update cluster with 1 workers [2021-08-09T07:12:45.390] [WARN] nodeJS - update cluster with 1 workers [2021-08-09T07:12:45.396] [WARN] nodeJS - worker 1161 started. [2021-08-09T07:12:45.398] [WARN] nodeJS - update cluster with 1 workers ==> /var/log/onlyoffice/documentserver/docservice/err.log <== ==> /var/log/onlyoffice/documentserver/docservice/out.log <== [2021-08-09T07:12:05.655] [WARN] nodeJS - Express server starting... [2021-08-09T07:12:05.657] [WARN] nodeJS - Failed to subscribe to plugin folder updates. When changing the list of plugins you must restart the server. https://nodejs.org/docs/latest/api/fs.html#fs_availability [2021-08-09T07:12:05.702] [WARN] nodeJS - Express server listening on port 8000 in production-linux mode. Version: 6.3.1. Build: 32 [2021-08-09T07:12:44.112] [WARN] nodeJS - Express server starting... [2021-08-09T07:12:44.113] [WARN] nodeJS - Failed to subscribe to plugin folder updates. When changing the list of plugins you must restart the server. https://nodejs.org/docs/latest/api/fs.html#fs_availability [2021-08-09T07:12:44.135] [WARN] nodeJS - Express server listening on port 8000 in production-linux mode. Version: 6.3.1. Build: 32 ==> /var/log/onlyoffice/documentserver/metrics/err.log <== ==> /var/log/onlyoffice/documentserver/metrics/out.log <== 9 Aug 07:12:05 - [998] reading config file: ./config/config.js 9 Aug 07:12:05 - server is up INFO ==> /var/log/onlyoffice/documentserver/nginx.error.log <== ==> /var/log/onlyoffice/documentserver/converter/out.log <== [2021-08-09T07:14:57.878] [ERROR] nodeJS - stdout (id=23--1628493219_1268): [2021-08-09T07:14:57.878] [ERROR] nodeJS - stderr (id=23--1628493219_1268):Uncaught TypeError: Cannot read property 'Kxa' of null DoctRenderer:<result><error index="-2" /></result> [2021-08-09T07:14:57.879] [ERROR] nodeJS - ExitCode (code=86;signal=null;error:-86;id=23--1628493219_1268) ``` **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.** Simple: 1. Edit (open) an XLSX file in OnlyOffice DocumentServer with AutoSave on (or off doesn't matter). 2. Add some text. 3. Close the file. 4. Wait 20 seconds. 5. Open the file again in OnlyOffice DocumentServer. 6. Notice the error. ***Note I use FileRun, a PHP based filemanager (a simple NextCloud alternative):*** https://filerun.com/ OnlyOffice is supported as plugin. The install base of FileRun contains the following within the plugin folder of OnlyOffice: - blanks (folder containing empty document files (templates/defaults)) - JWT (folder containing a few files probably to support JWT secret (which I have to enter in FileRun UI Settings). - `app.php` (see first comment below) - `display.php` (below) - `index.html` (0 bytes file) display.php: ``` <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title><?php echo \S::safeHTML(\S::forHTML($this->data['fileName']));?></title> <style> body { border: 0; margin: 0; padding: 0; overflow:hidden; } </style> </head> <body> <div id="placeholder"></div> <script type="text/javascript" src="<?php echo gluePath(self::getSetting('serverURL'), '/web-apps/apps/api/documents/api.js');?>"></script> <script> var docEditor = new DocsAPI.DocEditor("placeholder", <?php echo json_encode($opts);?>); </script> </body> </html> ``` I believe the issue might be within the `app.php` file, the newer versions of OnlyOffice DocumentServer probably require some change in the way it communicates with the filemanager. I hope, I really hope someone is willing to have a look and verify the `app.php` file is still correct. It seems the devteam of FileRun has moved a bit closer to LibreOffice server edition and not that interested in fixing this issue. I really hope I can get it fixed, because I am a BIG OnlyOffice fan. **What is the expected behavior?** No error, no loss of content. **Did this work in previous versions of DocumentServer?** Yes. **DocumentServer Docker tag:** Latest. **Host Operating System:** Ubuntu 21.04
kerem closed this issue 2026-02-26 10:30:48 +03:00
Author
Owner

@zilexa commented on GitHub (Aug 9, 2021):

As mentioned above, FileRun filemanager supports OnlyOffice as plugin and one of the files is display.php.
display.php:

<?php
use \FileRun\WebLinks;

class custom_onlyoffice extends \FileRun\Files\Plugin {

	public $weblinksCompatible = true;
	public $online = true;
	static $localeSection = 'Custom Actions: ONLYOFFICE';
	static $publicMethods = ['thumb', 'saveRemoteChanges'];

	var $canEditTypes = [
		'doc', 'docx', 'dotx', 'odt', 'ott', 'rtf', 'txt', 'html',
		'xls', 'xlsx', 'xltx', 'ods', 'ots', 'csv',
		'ppt', 'pptx', 'potx', 'odp', 'otp', 'pdf'
	];

	var $ext = [
		'text' => ['doc', 'docx', 'dotx', 'odt', 'ott', 'rtf', 'txt', 'pdf', 'html', 'epub', 'xps', 'djvu'],
		'spreadsheet' => ['xls', 'xlsx', 'xltx', 'ods', 'ots', 'csv'],
		'presentation' => ['ppt', 'pptx', 'potx', 'odp', 'otp'],
	];

	function init() {
		$this->settings = [
			[
				'key' => 'serverURL',
				'title' => self::t('DocumentServer URL'),
				'comment' => self::t('Download and install %1', ['<a href="https://github.com/ONLYOFFICE/DocumentServer" target="_blank">ONLYOFFICE DocumentServer</a>'])
			],
			[
                'key' => 'serverSecret',
                'title' => self::t('JWT secret')
            ],
			[
				'key' => 'allow_without_download',
				'title' => self::t('Allow previewing via web links without download permission.'),
				'type' => 'checkbox',
				'helpText' => self::t('Use this option only if your documents are not confidential.')
			]
		];
		$this->JSconfig = [
			"title" => self::t("ONLYOFFICE"),
			"popup" => true,
			'icon' => 'images/icons/onlyoffice.png',
			"loadingMsg" => self::t('Loading document in ONLYOFFICE. Please wait...'),
			'extensions' => array_merge($this->ext['text'], $this->ext['spreadsheet'], $this->ext['presentation']),
			"requires" => ["download"],
			"requiredUserPerms" => ["download"],
			"createNew" => [
				"title" => self::t("Document with ONLYOFFICE"),
				"options" => [
					[
						"fileName" => self::t("New Document.docx"),
						"title" => self::t("Word Document"),
						"iconCls" => 'fa fa-fw fa-file-word-o'
					],
					[
						"fileName" => self::t("New Spreadsheet.xlsx"),
						"title" => self::t("Spreadsheet"),
						"iconCls" => 'fa fa-fw fa-file-excel-o'
					],
					[
						"fileName" => self::t("New Presentation.pptx"),
						"title" =>  self::t("Presentation"),
						"iconCls" => 'fa fa-fw fa-file-powerpoint-o'
					]
				]
			]
		];
	}

	function isDisabled() {
		return (self::getSetting('serverURL') == '');
	}

	function run() {
		if ($this->isLimitedPreview() && !$this->getSetting('allow_without_download')) {
			$this->centeredThumb();
			return;
		}
		$version = $this->data['version'] ?: false;
		if ($this->data['weblink']) {
			$url = $this->data['weblink']['download_url'];
		} else {
			$weblinkInfo = WebLinks::createForService($this->data);
			if (!$weblinkInfo) {
				self::outputError('Failed to setup weblink', 'html');
			}
			$url = WebLinks::getURL([
				'id_rnd' => $weblinkInfo['id_rnd'],
				'download' => 1,
				'version' => $version
			]);
		}
		$this->logAction();

		$extension = \FM::getExtension($this->data['fileName']);

		$saveURL = false;
		$mode = 'view';
		if (!$_GET['preview_plugin']) {
			if (in_array($extension, $this->canEditTypes)) {
				if (!$this->isLimitedPreview() && \FileRun\Perms::check('upload')) {
					if ((!$this->data['shareInfo'] || ($this->data['shareInfo'] && $this->data['shareInfo']['perms_upload']))) {
						if ($this->data['weblink']) {
							$isEditable = WebLinks::verifyAllowEditing($this->data['weblink']['linkInfo']);
							if ($isEditable) {
								$saveURL = $this->actionURL . '&method=saveRemoteChanges';
							}
						} else {
							$saveURL = WebLinks::getSaveURL($weblinkInfo['id_rnd'], false, "onlyoffice");
						}
					}
				}
			}
		}
		if ($saveURL) {
			$mode = 'edit';
		}

		if (in_array($extension, $this->ext['text'])) {
			$docType = 'text';
		} else if (in_array($extension, $this->ext['spreadsheet'])) {
			$docType = 'spreadsheet';
		} else {
			$docType = 'presentation';
		}

		global $auth;
		$author = \FileRun\Users::formatFullName($auth->currentUserInfo);


		$fileModifTime = filemtime($this->data['fullPath']);

		$pid = \FileRun\Paths::getId($this->data['fullPath'], true);
		$documentKey = substr(implode('-',
			[$pid, $version, $fileModifTime]
		), 0, 20);

		$opts = [
			'documentType' => $docType,
			"type" => "desktop",
			"document" => [
				"fileType" => $extension,
				"key" => $documentKey,
				"title" => $this->data['fileName'],
				"url" => $url,
				"info" => [
					"author" => $author,
					"owner" => $author
				]
			],
			"editorConfig" => [
				"mode" => $mode,
				"lang" => "en",
				"location" => "en",
				"region" => "en-US",
				"user" => [
					"id" => $auth->currentUserInfo['id'],
					"name" => $author,
					"firstname" => $auth->currentUserInfo['name'],
					"lastname" => $auth->currentUserInfo['name2']
				],
				"customization" => [
					"autosave" => true,
					'about' => false,
					'comments' => false,
					'chat' => false,
					'feedback' => false,
					'goback' => false,
					'compactHeader' => true,
					'hideRightMenu' => true,
					'toolbarNoTabs' => true,
					'zoom' => -2,
					'logo' => ['url' => null]
				]
			],
			"events" => [
				'onError' => 'function (event) {
					if (event && docEditor) {
						docEditor.showMessage(event.data);
					}
				}'
			],
			"height" => "100%",
			"width" => "100%"
		];
		if ($this->isLimitedPreview()) {
			$opts['document']['permissions'] = [
				"edit" => false,
				"download" => false,
				"review" => false,
				'copy' => false,
				"fillForms" => false,
				"print" => false,
				"comment" => false,
				"editCommentsAuthorOnly" => true,
	            "deleteCommentsAuthorOnly" => true
			];
		}

		if ($mode == 'view') {
			$opts['type'] = 'embedded';
			$opts['editorConfig']['embedded'] = ['toolbarDocked' => 'bottom'];
		} else {
			$opts['editorConfig']['customization']['forcesave'] = true;
		}

		if ($saveURL) {
			$opts['editorConfig']['callbackUrl'] = $saveURL;
		}
		$secret = self::getSetting('serverSecret');
        if ($secret != '') {
            require $this->path . '/jwt/JWT.php';
            $opts['token'] = \Firebase\JWT\JWT::encode($opts, $secret);
        }

		require $this->path."/display.php";

		$this->logAction();
	}

	function saveRemoteChanges() {
		$rs = @file_get_contents("php://input");
		if ($rs === false) {
			self::outputError(error_get_last()['message'], 'text');
		}
		if (!$rs) {
			self::outputError('Empty contents.', 'text');
		}
		$rs = json_decode($rs, true);
		if ($rs["status"] != 2 && $rs["status"] != 6) {
			echo json_encode(['error' => 0]);
			return false;
		}
		$contents = @file_get_contents($rs["url"]);
		if ($contents === false) {
			self::outputError(error_get_last()['message'], 'text');
		}
		if (!$contents) {
			self::outputError('Empty contents.', 'text');
		}
		$this->writeFile([
			'source' => 'string',
			'contents' => $contents
		]);
		echo json_encode(['error' => 0]);
	}

	function createBlankFile() {
		$fileName = \S::fromHTML($_POST['fileName']);
		$this->data['relativePath'] = gluePath($this->data['relativePath'], $fileName);
		$ext = \FM::getExtension($fileName);
		if (!in_array($ext, $this->canEditTypes)) {
			jsonOutput([
				"rs" => false,
				"msg" => self::t('The file extension needs to be one of the following: %1', [implode(', ', $this->canEditTypes)])
			]);
		}
		$sourceFullPath = gluePath($this->path, 'blanks/blank.'.$ext);
		$this->writeFile([
			'source' => 'copy',
			'sourceFullPath' => $sourceFullPath
		]);
		jsonFeedback(true, 'Blank file created successfully');
	}
}
<!-- gh-comment-id:895015730 --> @zilexa commented on GitHub (Aug 9, 2021): As mentioned above, FileRun filemanager supports OnlyOffice as plugin and one of the files is display.php. display.php: ``` <?php use \FileRun\WebLinks; class custom_onlyoffice extends \FileRun\Files\Plugin { public $weblinksCompatible = true; public $online = true; static $localeSection = 'Custom Actions: ONLYOFFICE'; static $publicMethods = ['thumb', 'saveRemoteChanges']; var $canEditTypes = [ 'doc', 'docx', 'dotx', 'odt', 'ott', 'rtf', 'txt', 'html', 'xls', 'xlsx', 'xltx', 'ods', 'ots', 'csv', 'ppt', 'pptx', 'potx', 'odp', 'otp', 'pdf' ]; var $ext = [ 'text' => ['doc', 'docx', 'dotx', 'odt', 'ott', 'rtf', 'txt', 'pdf', 'html', 'epub', 'xps', 'djvu'], 'spreadsheet' => ['xls', 'xlsx', 'xltx', 'ods', 'ots', 'csv'], 'presentation' => ['ppt', 'pptx', 'potx', 'odp', 'otp'], ]; function init() { $this->settings = [ [ 'key' => 'serverURL', 'title' => self::t('DocumentServer URL'), 'comment' => self::t('Download and install %1', ['<a href="https://github.com/ONLYOFFICE/DocumentServer" target="_blank">ONLYOFFICE DocumentServer</a>']) ], [ 'key' => 'serverSecret', 'title' => self::t('JWT secret') ], [ 'key' => 'allow_without_download', 'title' => self::t('Allow previewing via web links without download permission.'), 'type' => 'checkbox', 'helpText' => self::t('Use this option only if your documents are not confidential.') ] ]; $this->JSconfig = [ "title" => self::t("ONLYOFFICE"), "popup" => true, 'icon' => 'images/icons/onlyoffice.png', "loadingMsg" => self::t('Loading document in ONLYOFFICE. Please wait...'), 'extensions' => array_merge($this->ext['text'], $this->ext['spreadsheet'], $this->ext['presentation']), "requires" => ["download"], "requiredUserPerms" => ["download"], "createNew" => [ "title" => self::t("Document with ONLYOFFICE"), "options" => [ [ "fileName" => self::t("New Document.docx"), "title" => self::t("Word Document"), "iconCls" => 'fa fa-fw fa-file-word-o' ], [ "fileName" => self::t("New Spreadsheet.xlsx"), "title" => self::t("Spreadsheet"), "iconCls" => 'fa fa-fw fa-file-excel-o' ], [ "fileName" => self::t("New Presentation.pptx"), "title" => self::t("Presentation"), "iconCls" => 'fa fa-fw fa-file-powerpoint-o' ] ] ] ]; } function isDisabled() { return (self::getSetting('serverURL') == ''); } function run() { if ($this->isLimitedPreview() && !$this->getSetting('allow_without_download')) { $this->centeredThumb(); return; } $version = $this->data['version'] ?: false; if ($this->data['weblink']) { $url = $this->data['weblink']['download_url']; } else { $weblinkInfo = WebLinks::createForService($this->data); if (!$weblinkInfo) { self::outputError('Failed to setup weblink', 'html'); } $url = WebLinks::getURL([ 'id_rnd' => $weblinkInfo['id_rnd'], 'download' => 1, 'version' => $version ]); } $this->logAction(); $extension = \FM::getExtension($this->data['fileName']); $saveURL = false; $mode = 'view'; if (!$_GET['preview_plugin']) { if (in_array($extension, $this->canEditTypes)) { if (!$this->isLimitedPreview() && \FileRun\Perms::check('upload')) { if ((!$this->data['shareInfo'] || ($this->data['shareInfo'] && $this->data['shareInfo']['perms_upload']))) { if ($this->data['weblink']) { $isEditable = WebLinks::verifyAllowEditing($this->data['weblink']['linkInfo']); if ($isEditable) { $saveURL = $this->actionURL . '&method=saveRemoteChanges'; } } else { $saveURL = WebLinks::getSaveURL($weblinkInfo['id_rnd'], false, "onlyoffice"); } } } } } if ($saveURL) { $mode = 'edit'; } if (in_array($extension, $this->ext['text'])) { $docType = 'text'; } else if (in_array($extension, $this->ext['spreadsheet'])) { $docType = 'spreadsheet'; } else { $docType = 'presentation'; } global $auth; $author = \FileRun\Users::formatFullName($auth->currentUserInfo); $fileModifTime = filemtime($this->data['fullPath']); $pid = \FileRun\Paths::getId($this->data['fullPath'], true); $documentKey = substr(implode('-', [$pid, $version, $fileModifTime] ), 0, 20); $opts = [ 'documentType' => $docType, "type" => "desktop", "document" => [ "fileType" => $extension, "key" => $documentKey, "title" => $this->data['fileName'], "url" => $url, "info" => [ "author" => $author, "owner" => $author ] ], "editorConfig" => [ "mode" => $mode, "lang" => "en", "location" => "en", "region" => "en-US", "user" => [ "id" => $auth->currentUserInfo['id'], "name" => $author, "firstname" => $auth->currentUserInfo['name'], "lastname" => $auth->currentUserInfo['name2'] ], "customization" => [ "autosave" => true, 'about' => false, 'comments' => false, 'chat' => false, 'feedback' => false, 'goback' => false, 'compactHeader' => true, 'hideRightMenu' => true, 'toolbarNoTabs' => true, 'zoom' => -2, 'logo' => ['url' => null] ] ], "events" => [ 'onError' => 'function (event) { if (event && docEditor) { docEditor.showMessage(event.data); } }' ], "height" => "100%", "width" => "100%" ]; if ($this->isLimitedPreview()) { $opts['document']['permissions'] = [ "edit" => false, "download" => false, "review" => false, 'copy' => false, "fillForms" => false, "print" => false, "comment" => false, "editCommentsAuthorOnly" => true, "deleteCommentsAuthorOnly" => true ]; } if ($mode == 'view') { $opts['type'] = 'embedded'; $opts['editorConfig']['embedded'] = ['toolbarDocked' => 'bottom']; } else { $opts['editorConfig']['customization']['forcesave'] = true; } if ($saveURL) { $opts['editorConfig']['callbackUrl'] = $saveURL; } $secret = self::getSetting('serverSecret'); if ($secret != '') { require $this->path . '/jwt/JWT.php'; $opts['token'] = \Firebase\JWT\JWT::encode($opts, $secret); } require $this->path."/display.php"; $this->logAction(); } function saveRemoteChanges() { $rs = @file_get_contents("php://input"); if ($rs === false) { self::outputError(error_get_last()['message'], 'text'); } if (!$rs) { self::outputError('Empty contents.', 'text'); } $rs = json_decode($rs, true); if ($rs["status"] != 2 && $rs["status"] != 6) { echo json_encode(['error' => 0]); return false; } $contents = @file_get_contents($rs["url"]); if ($contents === false) { self::outputError(error_get_last()['message'], 'text'); } if (!$contents) { self::outputError('Empty contents.', 'text'); } $this->writeFile([ 'source' => 'string', 'contents' => $contents ]); echo json_encode(['error' => 0]); } function createBlankFile() { $fileName = \S::fromHTML($_POST['fileName']); $this->data['relativePath'] = gluePath($this->data['relativePath'], $fileName); $ext = \FM::getExtension($fileName); if (!in_array($ext, $this->canEditTypes)) { jsonOutput([ "rs" => false, "msg" => self::t('The file extension needs to be one of the following: %1', [implode(', ', $this->canEditTypes)]) ]); } $sourceFullPath = gluePath($this->path, 'blanks/blank.'.$ext); $this->writeFile([ 'source' => 'copy', 'sourceFullPath' => $sourceFullPath ]); jsonFeedback(true, 'Blank file created successfully'); } } ```
Author
Owner

@ShockwaveNN commented on GitHub (Aug 9, 2021):

Hi

Seems this problem is on side of FileRun connector, somehow it not correctly save file, I can think of a lot different reason, like connection issue or just even bug in connector code

FileRun connector for DocumentServer is not written by us, but from FireRun team, so you better connect their support or github

<!-- gh-comment-id:895017432 --> @ShockwaveNN commented on GitHub (Aug 9, 2021): Hi Seems this problem is on side of FileRun connector, somehow it not correctly save file, I can think of a lot different reason, like connection issue or just even bug in connector code FileRun connector for DocumentServer is not written by us, but from FireRun team, so you better connect their support or github
Author
Owner

@zilexa commented on GitHub (Aug 9, 2021):

Yes I agree, it must be with their connector side. I raised the issue a while ago already with FileRun.
Today I noticed their documentation (docs.filerun.com), which had an example docker-compose.yml that included OnlyOffice Documentserver is gone and they now provide instructions for LibreOffice. As I prefer OnlyOffice for so many reasons, I feel a bit lost now.

I was hoping to get a hint about what changed with OnlyOffice... especially for XLSX, since the FileRun connector did not change.
Note there are zero issues with DOCX files. It's really XLSX only.

And when I do the following, with Autosave disabled in OnlyOffice:

  1. create an XLSX file.
  2. add some text.
  3. File > Save.
    I get this error, I believe this is the issue. It can't save XLSX anymore:
    Screenshot_1

I'll keep asking their support.. I am not an enterprise user, just a big fan of both FileRun and OnlyOffice and an active contributor to the FileRun feedback forum.

<!-- gh-comment-id:895021065 --> @zilexa commented on GitHub (Aug 9, 2021): Yes I agree, it must be with their connector side. I raised the issue a while ago already with FileRun. Today I noticed their documentation (docs.filerun.com), which had an example docker-compose.yml that included OnlyOffice Documentserver is gone and they now provide instructions for LibreOffice. As I prefer OnlyOffice for so many reasons, I feel a bit lost now. I was hoping to get a hint about what changed with OnlyOffice... especially for XLSX, since the FileRun connector did not change. Note there are zero issues with DOCX files. It's really XLSX only. And when I do the following, with Autosave disabled in OnlyOffice: 1. create an XLSX file. 2. add some text. 3. File > Save. I get this error, I believe this is the issue. It can't save XLSX anymore: ![Screenshot_1](https://user-images.githubusercontent.com/3430004/128674358-f54116b4-803a-494c-830b-fcc03d5aceaa.png) I'll keep asking their support.. I am not an enterprise user, just a big fan of both FileRun and OnlyOffice and an active contributor to the FileRun feedback forum.
Author
Owner

@ShockwaveNN commented on GitHub (Aug 9, 2021):

I get this error, I believe this is the issue. It can't save XLSX anymore:

This error mean that DocumentServer cannot save result file on FileRun side
This may be simple connection issue (incorrect network setting, very strict firewall or similar) but maybe something more complicated

<!-- gh-comment-id:895025965 --> @ShockwaveNN commented on GitHub (Aug 9, 2021): > I get this error, I believe this is the issue. It can't save XLSX anymore: This error mean that DocumentServer cannot save result file on FileRun side This may be simple connection issue (incorrect network setting, very strict firewall or similar) but maybe something more complicated
Author
Owner

@ShockwaveNN commented on GitHub (Dec 5, 2021):

This issue was closed due to no response.

<!-- gh-comment-id:986256814 --> @ShockwaveNN commented on GitHub (Dec 5, 2021): This issue was closed due to no response.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Docker-DocumentServer-ONLYOFFICE#192
No description provided.