FriendsOfTYPO3 / frontend_editing

TYPO3 CMS Frontend Editing
https://friendsoftypo3.github.io/frontend_editing/
102 stars 38 forks source link

Error when saving inline editable content #506

Closed MattiasNilsson closed 3 years ago

MattiasNilsson commented 3 years ago

Error when saving inline editable content and it started with this Pull Request (https://github.com/FriendsOfTYPO3/frontend_editing/pull/502).

See screenshot.

Screenshot 2021-03-24 at 07 22 08
MattiasNilsson commented 3 years ago

@Messj1 Maybe you can take a quick look at it?

Messj1 commented 3 years ago

@MattiasNilsson I need more information. :wink: But was i can say is:

I was wondering, was the value on line 69 is log.debug('setEndpointUrl', url); :mag: ToDo: go into Development Tool -> Console and type: localStorage.setItem('log', 'log;FEditing:CRUD=debug') This will set log level to debug in Crud and level log on every thing else.

Then do it again and show me the log. :upside_down_face:

I love the new logging system :smiling_face_with_three_hearts:

:question: BTW: Why do you have an loading screen on your screenshot? It should call in every case the requestCompleted method. If there is a problem too with that: you should also check if items count log.debug('items to save', items); on line 116 match the count of logs log.debug('save item', item); on line 125 and log.debug('request if record is locked.', lockedRecordData); on line 171

MattiasNilsson commented 3 years ago

@Messj1 Just open and inline edit something then save. All the errors occurs. Yes the new logging is nice :) Do you need something more to debug it?

Messj1 commented 3 years ago

@Messj1 Just open and inline edit something then save. All the errors occurs. Yes the new logging is nice :) Do you need something more to debug it?

Are you working in 2.0 branch?

MattiasNilsson commented 3 years ago

@Messj1 Yes but not with this one. This error is in master branch. Just inline edit a element and click the Save All button and you will see the error. This occurs in Chrome for me.

Messj1 commented 3 years ago

Need more information.

  1. Can you go to Network Tab in Development Tool and show me the request and response of the XHR request
  2. Can you give me your log informations as already asked:

    ToDo: go into Development Tool -> Console and type: localStorage.setItem('log', 'log;FEditing:CRUD=debug') This will set log level to debug in Crud and level log on every thing else.

On my side it works. But it doesn't mean anything than i can't see anything :raised_eyebrow:

MattiasNilsson commented 3 years ago

@Messj1 Sure here is request:

POST /typo3/index.php?route=%2Fajax%2Ffrontend-editing%2Fprocess&token=44498bbb2bc0de93f00ed17693be865c030aa165&page=310&action=lockedRecord HTTP/1.1 Host: typo3-site.ddev.site Connection: keep-alive Content-Length: 44 Accept: */* X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36 Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Origin: http://typo3-site.ddev.site Referer: http://typo3-site.ddev.site/content-examples/text/rich-text Accept-Encoding: gzip, deflate Accept-Language: en-GB,en-US;q=0.9,en;q=0.8 Cookie: cookieconsent_status=dismiss; Typo3InstallTool=27a18c83f660159293a6cd2cde8e528a; be_typo_user=429d33d385e544cfc20c778cfd917617

Here is the respone:

HTTP/1.1 200 OK Server: nginx/1.18.0 Date: Wed, 24 Mar 2021 17:38:31 GMT Content-Type: text/html; charset=UTF-8 Transfer-Encoding: chunked Connection: keep-alive Vary: Accept-Encoding X-Frame-Options: SAMEORIGIN Expires: 0 Last-Modified: Wed, 24 Mar 2021 17:38:31 GMT Cache-Control: no-cache, must-revalidate Pragma: no-cache Content-Encoding: gzip

With and empty response body! It works if I go one commit back.

This is the debug log:

​​i FEditing:GUI 7234ms save items Crud.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:345 ​​x FEditing:CRUD response is no JSON. SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at getJsonResponse (Crud.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:343) at Object.success (Crud.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:182) at fire (jquery.js?1615889749:3291) at Object.fireWith [as resolveWith] (jquery.js?1615889749:3421) at done (jquery.js?1615889749:9533) at XMLHttpRequest.<anonymous> (jquery.js?1615889749:9785) getJsonResponse @ Crud.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:345 success @ Crud.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:182 fire @ jquery.js?1615889749:3291 fireWith @ jquery.js?1615889749:3421 done @ jquery.js?1615889749:9533 (anonymous) @ jquery.js?1615889749:9785 load (async) send @ jquery.js?1615889749:9804 ajax @ jquery.js?1615889749:9434 checkIfRecordIsLocked @ Crud.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:173 processSaveItem @ Crud.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:123 (anonymous) @ immutable.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:1379 ArrayMapNode.iterate.HashCollisionNode.iterate @ immutable.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:1728 Map.__iterate @ immutable.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:1377 forEach @ immutable.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:4383 saveAll @ Crud.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:118 save @ GUI.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:282 dispatch @ jquery.js?1615889749:5242 elemData.handle @ jquery.js?1615889749:5049 Crud.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:351 Uncaught TypeError: response was not a JSON at getJsonResponse (Crud.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:351) at Object.success (Crud.js?bust=83ac08affa0376ec4b17ed9bc78b81f79195c7bc:182) at fire (jquery.js?1615889749:3291) at Object.fireWith [as resolveWith] (jquery.js?1615889749:3421) at done (jquery.js?1615889749:9533) at XMLHttpRequest.<anonymous> (jquery.js?1615889749:9785)

Messj1 commented 3 years ago

@MattiasNilsson Definitely my fault: was a wrong test :facepalm: Yes, the error occurs if a empty string get respond. And if no lock was found no output get produced.

action=lockedRecord returns currently on

better would be to use something like:

Hint: Translation can be done on client

This should be improved later. For a fast hack i will do an fix as workaround in checkIfRecordIsLocked method. :raised_eyebrow: