nextcloud / documentserver_community

Document server for onlyoffice
https://apps.nextcloud.com/apps/documentserver_community
133 stars 29 forks source link

Document won't save - cannot set property '$k' of undefined #79

Open BornToBeRoot opened 4 years ago

BornToBeRoot commented 4 years ago

Hello,

i had a document that won't save and now i get this error every time the cron job runs:

[documentserver_community] Error: OCA\DocumentServer\Document\DocumentConversionException: change_code: !0!==this.xz?this.Ua:this.ym[a]);if(!1!==e){var h=d.fa.splice(e,1);d.IW(h);AscCommon.Rd.H4(d,e,1);0<e?e<=d.fa.length-1?(d.fa[e-1].$k=d.fa[e],d.fa[e].pk=d.fa[e-1]):d.fa[e-1].$k=null:e<=d.fa.length-1&&(d.fa[e].pk=null);0<=e&&e<=d.fa.length-1&&(d.sh&&d.sh.Nma(e,1),d.j4(e))}}};ak.prototype.vR=function(d){return this.Oa!==d.Oa||AscDFH.aya!==d.ka&&AscDFH.bya!==d.ka?!1:!0};ak.prototype.Mm=function(){return this.DR(Fr)};kl.prototype=Object.create(AscDFH.nm.prototype);kl.prototype.constructor=kl;kl.prototype.ka=
change: Uncaught TypeError: Cannot set property '$k' of undefined
DoctRenderer:<result><error index="3790" /></result>
 at <<closure>>

0. /var/www/html/nextcloud/apps/documentserver_community/lib/DocumentConverter.php line 123
   OCA\DocumentServer\Document\ConverterBinary->run("/tmp/oc_tmp_wpPIBz-.xml", null)
1. /var/www/html/nextcloud/apps/documentserver_community/lib/DocumentConverter.php line 78
   OCA\DocumentServer\DocumentConverter->runCommand(OCA\DocumentServ ... {})
2. /var/www/html/nextcloud/apps/documentserver_community/lib/Document/DocumentStore.php line 151
   OCA\DocumentServer\DocumentConverter->saveChanges("*** sensitive parameter replaced ***", ["78;AgAAADEA//8 ... "], "/srv/nextcloud- ... t", "odt")
3. /var/www/html/nextcloud/apps/documentserver_community/lib/LocalAppData.php line 100
   OCA\DocumentServer\Document\DocumentStore->OCA\DocumentServer\Document\{closure}("*** sensitive parameters replaced ***")
4. /var/www/html/nextcloud/apps/documentserver_community/lib/Document/DocumentStore.php line 164
   OCA\DocumentServer\LocalAppData->getReadWriteLocalPath(OC\Files\SimpleFS\SimpleFolder {}, Closure {})
5. /var/www/html/nextcloud/apps/documentserver_community/lib/Document/SaveHandler.php line 56
   OCA\DocumentServer\Document\DocumentStore->saveChanges(627642030, [OCA\DocumentSer ... }])
6. /var/www/html/nextcloud/apps/documentserver_community/lib/BackgroundJob/Cleanup.php line 69
   OCA\DocumentServer\Document\SaveHandler->flushChanges(627642030)
7. /var/www/html/nextcloud/lib/public/BackgroundJob/Job.php line 79
   OCA\DocumentServer\BackgroundJob\Cleanup->run(null)
8. /var/www/html/nextcloud/cron.php line 125
   OCP\BackgroundJob\Job->execute(OC\BackgroundJob\JobList {}, OC\Log {})

I can also reproduce this error with occ documentserver:flush

Any idea how i can remove the corrupted file? I tried reinstalling documentserver_community + ONLYOFFICE without success.

BornToBeRoot commented 4 years ago

I removed the doc_xxxxxxxxxx folder in der nextcloud data\appdata_xxx \documentserver_community

Running occ documentserver:flush now works.

ogmkp commented 4 years ago

Same bug here.

zv1n commented 4 years ago

This error is coming from the onlyoffice/sdkjs/word/Editor/DocumentChanges.js:340.

There are a few other spots where the error is possible. This was for the Load method specifically, but there are other methods that have very similar code that I didn't fix.

Apparently line 312:

var Pos = oDocument.m_oContentChanges.Check(AscCommon.contentchanges_Remove, true !== this.UseArray ? this.Pos : this.PosArray[nIndex]);

Pos can be greater than oDocument.Contents.length; Setting oDocument.Contents[Pos-1].Next = null will result in an error in these cases.

I was able to fix the issue by changing:

d.fa[a-1].$k=null

to

(d.fa[a-1]&&(d.fa[a-1].$k=null))

at apps/documentserver_community/3rdparty/onlyoffice/documentserver/sdkjs/word/sdk-all.js:7996.

After this change, everything appears to saving out correctly. This could obviously be a more complex, systemic issue within the sdkjs library. Definitely recommend forwarding the issue along to the ONLYOFFICE folk.

Software Version
NextCloud 18.0.4
Document Server v0.1.5
ONLYOFFICE v4.1.4

YMMV.

mariusbolik commented 4 years ago

Having the same problem when using images in the document. I can't open the document anymore.

TheRealThor commented 4 years ago

Just had the same bug. I pressed a couple of times enter on a template and suddenly the page disappeared. Reloading did not work and the document opend in libreoffice was empty. I got this error:

change: Uncaught TypeError: Cannot read property 'b8d' of undefined DoctRenderer: namespace error : Namespace prefix wp14 on sizeRelH is not defined ame="" hidden="false"/><wp14:sizeRelH relativeFrom="page" (...)

antonbrall commented 3 years ago

I removed the doc_xxxxxxxxxx folder in der nextcloud data\appdata_xxx \documentserver_community

Running occ documentserver:flush now works.

This also worked for me, but for me the error message was about the document Server only Supporting 20 People.