Bug #80481

Story #69617: FormEngine bugs

FormEngine.Validation may access DOM too early

Added by Markus Klein almost 3 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Must have
Assignee:
Category:
Backend JavaScript
Target version:
Start date:
2017-03-27
Due date:
% Done:

100%

TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
medium
Is Regression:
No
Sprint Focus:
Stabilization Sprint

Description

The initialization function of FormEngine.Validation is not registered as DOMready handler, but is called directly. This will cause problems on browsers with very fast JS evaluation, where the DOM is not yet ready.


Related issues

Related to TYPO3 Core - Bug #80672: Saving problems in Chrome 57+ Closed 2017-04-04
Related to TYPO3 Core - Bug #80632: still issues with missing input in BE Closed 2017-04-02
Related to TYPO3 Core - Bug #81520: form validation in backend not working onload Closed 2017-06-08

Associated revisions

Revision 976934a3 (diff)
Added by Markus Klein almost 3 years ago

[BUGFIX] JS: Fix FormEngine initialization

The FormEngine initialization process needs to be very careful
when the DOM is accessed.
This patch separates the routines and encapsulates those in
a DOMready handler, which are critical.

This solves a possible race condition when JS is executed faster
than DOM is built.

Releases: master, 7.6
Resolves: #80481
Resolves: #80366
Change-Id: I205aebc9f87a25f06942f923497f7f535fdb0c8f
Reviewed-on: https://review.typo3.org/52180
Tested-by: TYPO3com <>
Reviewed-by: Benni Mack <>
Reviewed-by: Wouter Wolters <>
Reviewed-by: Stefan Neufeind <>
Reviewed-by: Thomas Maroschik <>
Tested-by: Thomas Maroschik <>
Reviewed-by: Frank Naegler <>
Tested-by: Frank Naegler <>

Revision e6b3d3c3 (diff)
Added by Markus Klein almost 3 years ago

[BUGFIX] JS: Fix FormEngine initialization

The FormEngine initialization process needs to be very careful
when the DOM is accessed.
This patch separates the routines and encapsulates those in
a DOMready handler, which are critical.

This solves a possible race condition when JS is executed faster
than DOM is built.

Releases: master, 7.6
Resolves: #80481
Resolves: #80366
Change-Id: I205aebc9f87a25f06942f923497f7f535fdb0c8f
Reviewed-on: https://review.typo3.org/52208
Tested-by: TYPO3com <>
Reviewed-by: Markus Klein <>
Tested-by: Markus Klein <>

History

#1 Updated by Gerrit Code Review almost 3 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52180

#2 Updated by Gerrit Code Review almost 3 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52180

#3 Updated by Gerrit Code Review almost 3 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52180

#4 Updated by Gerrit Code Review almost 3 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52180

#5 Updated by Gerrit Code Review almost 3 years ago

Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52208

#6 Updated by Gerrit Code Review almost 3 years ago

Patch set 2 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52208

#7 Updated by Gerrit Code Review almost 3 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52180

#8 Updated by Gerrit Code Review almost 3 years ago

Patch set 3 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52208

#9 Updated by Gerrit Code Review almost 3 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52180

#10 Updated by Markus Klein almost 3 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#11 Updated by José Ricardo almost 3 years ago

I'm still getting the problem on TYPO3 7.6.18. Anyone else?

#12 Updated by Markus Klein almost 3 years ago

@josé: Can you please describe what error you see? What behaviour do you experience? Any log messages in console?

#13 Updated by José Ricardo almost 3 years ago

No errors logged.
Here at my office we don't see the error (just got it once), but our costumer reports that often some news records (tx_news) are saved without title. They use Google Chrome + Windows (we recommended they to use Firefox by now to see if the error incidence goes down). The only thing logged in sys_log is this kind of message (no errors on any log):

Record '[Sem título]' (tx_news_domain_model_news:414408) was inserted on page 'Acervo de Notícias' (3) (msg#1.1.10)

'Sem título' means 'No title' in brazilian portuguese.
This is an inconsistent error, since we couldn't find at the moment any pattern involving it.
As the title is the only required field and the only field which is lost after saving, i'm starting believing it could be related.

This is happening on about 5~10% of the records inserted and to all users.

#14 Updated by Markus Klein almost 3 years ago

Yes I can confirm this issue as well. I saw that myself too, but this is not a bug anymore in TYPO3, it's a matter of waiting long enough to let form initialize.
If you do not wait long enough and start typing too fast, then this can happen. I currently have no clue if this is fixable without blocking the user's view (like hiding everything) until all stuff is initialized properly.

#15 Updated by Riccardo De Contardi almost 3 years ago

That happened to me while creating a BE usergroup: the required field was actually saved as "[No title]"

This should be related, right? #80672

See also #80632 #80884

#16 Updated by José Ricardo almost 3 years ago

I confirm that it's a problem related to speed of user input against the form initialization.

On Chrome i've changed throttling preset to GPRS, so I cloud simulate a very slow connection. Before the form completed I was able to save the news record without selecting Categories (which are required in my project) and the title was lost.

Shouldn't TYPO3 block saving or typing anything on the forms before it's fully loaded? As there's no server-side validation of required fields, this behaviour could lead to errors on the system if those exceptions (like not having a category) are not handled.

#17 Updated by Riccardo De Contardi almost 3 years ago

Another possibly related: #77729

#18 Updated by Riccardo De Contardi almost 3 years ago

  • Parent task set to #69617

#19 Updated by Christian Hillebrand almost 3 years ago

just came in this trouble and my browser (google chrome) is telling me the following:

Uncaught TypeError: FormEngineValidation.registerReady is not a function
    index.php?route=%2Frecord%2Fedit&token=ab86687…&edit[tt_content][20…:155 
    at index.php?route=%2Frecord%2Fedit&token=ab86687…&edit[tt_content][20…:155
    at Object.execCb (require-1604a50….js:1)
    at t.check (require-1604a50….js:1)
    at t.<anonymous> (require-1604a50….js:1)
    at require-1604a50….js:1
    at require-1604a50….js:1
    at each (require-1604a50….js:1)
    at t.emit (require-1604a50….js:1)
    at t.check (require-1604a50….js:1)
    at t.enable (require-1604a50….js:1)

and
Uncaught TypeError: FormEngine.setBrowserUrl is not a function
    index.php?route=%2Frecord%2Fedit&token=ab86687…&edit[tt_content][20…:149 
    at index.php?route=%2Frecord%2Fedit&token=ab86687…&edit[tt_content][20…:149
    at Object.execCb (require-1604a50….js:1)
    at t.check (require-1604a50….js:1)
    at t.<anonymous> (require-1604a50….js:1)
    at require-1604a50….js:1
    at require-1604a50….js:1
    at each (require-1604a50….js:1)
    at t.emit (require-1604a50….js:1)
    at t.check (require-1604a50….js:1)
    at t.<anonymous> (require-1604a50….js:1)


when i check the script at this position, there is:

/*RequireJS-Module-TYPO3/CMS/Backend/FormEngined935ebd2ae27fe1f92ebe73abca953afd001513e*/
require(["TYPO3/CMS/Backend/FormEngine"], function(FormEngine) {
            FormEngine.setBrowserUrl('\/typo3\/index.php?route=%2Fwizard%2Frecord%2Fbrowse\u0026token=2836d0b1a12176fd49ebe29df35a23dc2679be42');
        });

/*RequireJS-Module-TYPO3/CMS/Backend/FormEngineValidationdfe861477e946addc2b2ba604b52bdb6630146a5*/
require(["TYPO3/CMS/Backend/FormEngineValidation"], function(FormEngineValidation) {
            FormEngineValidation.setUsMode(0);
            FormEngineValidation.registerReady();
        });

While i am on the URL: https://..../typo3/index.php?route=%2Fmain&token=101e14d3018533802a55e2129cc0bc855c62e67e

does this maybe matter?

on firefox i get allmost the same ... just another set of token

#20 Updated by Markus Klein almost 3 years ago

@Christian: Can you please flush your browser's cache! There is actually no other cause for your errors, because the missing functions have been added and are new. Since your browser does not know them, it is clear it uses old files.

#21 Updated by Markus Klein almost 3 years ago

  • Related to Bug #80672: Saving problems in Chrome 57+ added

#22 Updated by Markus Klein almost 3 years ago

  • Related to Bug #80632: still issues with missing input in BE added

#23 Updated by Markus Klein almost 3 years ago

Please continue in #80672.

#24 Updated by Christian Hillebrand almost 3 years ago

i even installed an update in chrome ... so i restarted chrome multiple times ... it did not changed anything ... i wasn't able to see any form contents

now ... 30 minutes later it seems to work again ... without doing anything further :P

#25 Updated by Markus Klein almost 3 years ago

Updating Chrome does not flush its caches ;-)

#26 Updated by Christian Hillebrand almost 3 years ago

i did not flush the cache manually at any time - but its working now for any reason ;)

and i used the developer tools with "disable cache" enabled

#27 Updated by Oliver Hader over 2 years ago

  • Related to Bug #81520: form validation in backend not working onload added

#28 Updated by Benni Mack over 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF