Bug #64930

Infinite javascript loop when trying to add new IRRE element with RTE fields

Added by Frans Saris 6 months ago. Updated 6 months ago.

Status:Resolved Start date:2015-02-08
Priority:Must have Due date:
Assigned To:Nicole Cordes % Done:

100%

Category:Backend User Interface Spent time: -
Target version:-
TYPO3 Version:7 Is Regression:Yes
PHP Version: Sprint Focus:Stabilization Sprint
Complexity:

Description

If you try to create a new child element with an RTE element the javascript get into a infinite loop in TYPO3/CMS/Rtehtmlarea/HTMLArea/Util/String

    String.prototype.ellipsis = function(length) {
        var temp = this;
        var trimmed = this;
        if (temp.visualLength() > length) {
            trimmed += "...";
            while (trimmed.visualLength() > length) {
                temp = temp.substring(0, temp.length-1);
                    trimmed = temp + "...";
            }
        }
        return trimmed;
    };

Also opening existing children give issues

TYPO3.settings.Textarea.autosize undefined


Related issues

related to Core - Bug #62440: RTE is not loaded when creating new child or when all chi... Resolved 2014-10-24

Associated revisions

Revision 67a67d3e
Added by Stanislas Rolland 6 months ago

[BUGFIX] Prevent Javascript loop for RTE-enabled fields

Problem: If a collapsed IRRE element with a RTE-enabled field is added,
a JavaScript loop is triggered because of missing widths of the select
fields within the RTE toolbar. This is caused by change in the way IRRE
nested inline elements are made visible using class attribute rather than
display property of style attribute. This also applies to new tab menus.
The change also affects the properties of the nested elements whose
mutations must be observe in order to detect when the RTE iframe becomes
visible.
Solution: Adjust the list of attributes to be observed on nested inline
elements. Adjust also detection of nested elements visibility state as
well as the walk to make them hidden with the visibility property of
the style attribute while the RTE framework is being rendered.

There is also a check added for TYPO3.settings.Textarea that is not
present when RTE fields are hidden by DisplayCond for a child element
that gets expanded/opened.

Releases: master
Resolves: #64930
Change-Id: I6f3bea4e9e72c33f2ae773734e9e6d794fe38ee9
Reviewed-on: http://review.typo3.org/36860
Reviewed-by: Nicole Cordes <>
Tested-by: Nicole Cordes <>
Reviewed-by: Stanislas Rolland <>
Tested-by: Stanislas Rolland <>

History

#1 Updated by Frans Saris 6 months ago

  • Sprint Focus set to Stabilization Sprint

#2 Updated by Stanislas Rolland 6 months ago

Please test this change: https://review.typo3.org/#/c/34706/

#3 Updated by Frans Saris 6 months ago

Still got a infinite loop at http://master.typo3.local/typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/HTMLArea/Util/String.js?1421954776:57 when creating/adding a new record. At least that is the message from FireFox.

Opening a existing IRRE element works with the patch.

#4 Updated by Frans Saris 6 months ago

Did some extra test but the patch doesn't resolve any of the mentioned bugs. If there are visible RTE fields is works also without the patch for existing IRRE elements.
If displayCond prevents the RTE from being shown you get the following error (also only for existing IRRE records):

TypeError: TYPO3.settings.Textarea is undefined
http://master.typo3.local/typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js
Line 635

#5 Updated by Nicole Cordes 6 months ago

  • Status changed from New to Needs Feedback

Can't verify this neither with Firefox nor with Chrome. Any special settings in TCA needed? I have a parent element with children by using foreign_selector

#6 Updated by Frans Saris 6 months ago

  • Status changed from Needs Feedback to New

Here the TCA that gives troubles

<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}

return array(
    'ctrl' => array(
        'requestUpdate' => 'all_day,allow_subscribing',
        'title' => 'LLL:EXT:eventsmanager/Resources/Private/Language/locallang_db.xml:tx_eventsmanager_domain_model_event',
        'label' => 'title',
        'tstamp' => 'tstamp',
        'crdate' => 'crdate',
        'dividers2tabs' => TRUE,
        'versioningWS' => 2,
        'versioning_followPages' => TRUE,
        'origUid' => 't3_origuid',
        'languageField' => 'sys_language_uid',
        'transOrigPointerField' => 'l10n_parent',
        'transOrigDiffSourceField' => 'l10n_diffsource',
        'delete' => 'deleted',
        'enablecolumns' => array(
            'disabled' => 'hidden',
            'starttime' => 'starttime',
            'endtime' => 'endtime',
            'fe_group' => 'fe_group',
        ),
        'searchFields' => 'title, teaser, description,',
        'requestUpdate' => 'parent_event',
        'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('eventsmanager') . 'Resources/Public/Icons/tx_eventsmanager_domain_model_event.gif'
    ),
    'interface' => array(
        'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, title, teaser, description, images, fe_group, categories, linked_events',
    ),
    'types' => array(
        '1' => array('showitem' => '
                    --div--;LLL:EXT:eventsmanager/Resources/Private/Language/locallang_db.xml:tabs.general,
                    --palette--;LLL:EXT:eventsmanager/Resources/Private/Language/locallang_db.xml:palette.event;title,
                    teaser;;;richtext:rte_transform[flag=rte_enabled|mode=ts],
                    description;;;richtext:rte_transform[flag=rte_enabled|mode=ts],
                    images,
                    linked_events,
                    categories,
                    fe_group'),
    ),
    'palettes' => array(
        'title' => array('showitem' => 'title, hidden, --linebreak--, parent_event', 'canNotCollapse' => 1),
    ),
    'columns' => array(
        'sys_language_uid' => array(
            'exclude' => 1,
            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.language',
            'config' => array(
                'type' => 'select',
                'foreign_table' => 'sys_language',
                'foreign_table_where' => 'ORDER BY sys_language.title',
                'items' => array(
                    array('LLL:EXT:lang/locallang_general.xml:LGL.allLanguages', -1),
                    array('LLL:EXT:lang/locallang_general.xml:LGL.default_value', 0)
                ),
            ),
        ),
        'l10n_parent' => array(
            'displayCond' => 'FIELD:sys_language_uid:>:0',
            'exclude' => 1,
            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.l18n_parent',
            'config' => array(
                'type' => 'select',
                'items' => array(
                    array('', 0),
                ),
                'foreign_table' => 'tx_eventsmanager_domain_model_event',
                'foreign_table_where' => 'AND tx_eventsmanager_domain_model_event.pid=###CURRENT_PID### AND tx_eventsmanager_domain_model_event.sys_language_uid IN (-1,0)',
            ),
        ),
        'l10n_diffsource' => array(
            'config' => array(
                'type' => 'passthrough',
            ),
        ),
        't3ver_label' => array(
            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.versionLabel',
            'config' => array(
                'type' => 'input',
                'size' => 30,
                'max' => 255,
            )
        ),
        'hidden' => array(
            'exclude' => 1,
            'label' => 'LLL:EXT:eventsmanager/Resources/Private/Language/locallang_db.xml:field.hidden',
            'config' => array(
                'type' => 'check',
            ),
        ),
        'starttime' => array(
            'exclude' => 1,
            'l10n_mode' => 'mergeIfNotBlank',
            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.starttime',
            'config' => array(
                'type' => 'input',
                'size' => 13,
                'max' => 20,
                'eval' => 'datetime',
                'checkbox' => 0,
                'default' => 0
            ),
        ),
        'endtime' => array(
            'exclude' => 1,
            'l10n_mode' => 'mergeIfNotBlank',
            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.endtime',
            'config' => array(
                'type' => 'input',
                'size' => 13,
                'max' => 20,
                'eval' => 'datetime',
                'checkbox' => 0,
                'default' => 0
            ),
        ),
        'title' => array(
            'exclude' => 0,
            'label' => 'LLL:EXT:eventsmanager/Resources/Private/Language/locallang_db.xml:tx_eventsmanager_domain_model_event.title',
            'config' => array(
                'type' => 'input',
                'size' => 30,
                'eval' => 'trim,required'
            ),
        ),

        'parent_event' => array(
            'exclude' => 1,
            'label' => 'LLL:EXT:eventsmanager/Resources/Private/Language/locallang_db.xml:tx_eventsmanager_domain_model_event.parent_event',
            'config' => array(
                'type' => 'group',
                'internal_type' => 'db',
                'allowed' => 'tx_eventsmanager_domain_model_event',
                'minitems' => 0,
                'maxitems' => 1,
                'size' => 1,
                'wizards' => array(
                    'suggest' => array(
                        'type' => 'suggest',
                    ),
                ),
            ),
        ),
        'teaser' => array(
            'exclude' => 1,
            'displayCond' => 'FIELD:parent_event:<:1',
            'label' => 'LLL:EXT:eventsmanager/Resources/Private/Language/locallang_db.xml:tx_eventsmanager_domain_model_event.teaser',
            'config' => array(
                'type' => 'text',
                'cols' => 40,
                'rows' => 5,
                'eval' => 'trim'
            ),
        ),
        'description' => array(
            'exclude' => 1,
            'displayCond' => 'FIELD:parent_event:<:1',
            'label' => 'LLL:EXT:eventsmanager/Resources/Private/Language/locallang_db.xml:tx_eventsmanager_domain_model_event.description',
            'config' => array(
                'type' => 'text',
                'cols' => 40,
                'rows' => 15,
                'eval' => 'trim'
            ),
        ),
        'images' => array(
            'exclude' => 1,
            'displayCond' => 'FIELD:parent_event:<:1',
            'l10n_mode' => 'mergeIfNotBlank',
            'label' => 'LLL:EXT:eventsmanager/Resources/Private/Language/locallang_db.xml:tx_eventsmanager_domain_model_event.images',
            'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
                'images',
                array(
                    'appearance' => array(
                        'createNewRelationLinkTitle' => 'LLL:EXT:eventsmanager/Resources/Private/Language/locallang_db.xml:tx_eventsmanager_domain_model_event.images.add'
                    ),
                ),
                $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
            )
        ),
        'categories' => array(
            'exclude' => 1,
            'l10n_mode' => 'exclude',
            'label' => 'LLL:EXT:eventsmanager/Resources/Private/Language/locallang_db.xlf:tx_eventsmanager_domain_model_event.categories',
            'config' => array(
                'type' => 'select',
                'foreign_table' => 'sys_category',
                'foreign_table_where' => ' AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.sorting ASC',
                'MM' => 'sys_category_record_mm',
                'MM_opposite_field' => 'items',
                'MM_match_fields' => array(
                    'tablenames' => 'tx_eventsmanager_domain_model_event',
                    'fieldname' => 'categories',
                ),
                'renderMode' => 'tree',
                'treeConfig' => array(
                    'parentField' => 'parent',
                    'appearance' => array(
                        'expandAll' => FALSE,
                        'showHeader' => TRUE,
                        'maxLevels' => 99,
                        'width' => 600,
                    ),
                ),
                'size' => 10,
                'autoSizeMax' => 20,
                'minitems' => 0,
                'maxitems' => 999,
            ),
        ),
        'linked_events' => array(
            'exclude' => 1,
            'displayCond' => 'FIELD:parent_event:<:1',
            'label' => 'LLL:EXT:eventsmanager/Resources/Private/Language/locallang_db.xml:tx_eventsmanager_domain_model_event.linked_events',
            'config' => array(
                'type' => 'inline',
                'foreign_table' => 'tx_eventsmanager_domain_model_event',
                'foreign_field' => 'parent_event',
                'maxitems' => 9999,
                'appearance' => array(
                    'newRecordLinkAddTitle' => TRUE,
                    'levelLinksPosition' => 'both',
                    'useSortable' => 0,
                    'collapseAll' => 1,
                    'expandSingle' => 0,
                    'enabledControls' => array(
                        'info' => 0,
                        'new' => 0,
                        'dragdrop' => 0,
                        'sort' => 0,
                        'hide' => 1,
                        'delete' => 1,
                        'localize' => 0
                    )
                )
            ),
        ),
        'fe_group' => array(
            'exclude' => 1,
            'label' => 'LLL:EXT:eventsmanager/Resources/Private/Language/locallang_db.xml:tx_eventsmanager_domain_model_event.fe_group',
            'config' => array(
                'type' => 'select',
                'size' => 5,
                'maxitems' => 20,
                'items' => array(
                    array(
                        'LLL:EXT:lang/locallang_general.xml:LGL.hide_at_login',
                        -1,
                    ),
                    array(
                        'LLL:EXT:lang/locallang_general.xml:LGL.any_login',
                        -2,
                    ),
                    array(
                        'LLL:EXT:lang/locallang_general.xml:LGL.usergroups',
                        '--div--',
                    ),
                ),
                'exclusiveKeys' => '-1,-2',
                'foreign_table' => 'fe_groups',
                'foreign_table_where' => 'ORDER BY fe_groups.title',
            ),
        ),
    ),
);

#7 Updated by Stanislas Rolland 6 months ago

Do you get the problem when the fields are not RTE-enabled in TCA?

#8 Updated by Frans Saris 6 months ago

With RTE disabled for those fields adding a new child element works, but opening an existing one still give the error

Uncaught TypeError: Cannot read property 'autosize' of undefined

#9 Updated by Nicole Cordes 6 months ago

  • Status changed from New to In Progress
  • Assigned To set to Nicole Cordes

Thanks for the TCA - have the same trouble now

#10 Updated by Gerrit Code Review 6 months ago

  • Status changed from In Progress 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 http://review.typo3.org/36860

#11 Updated by Nicole Cordes 6 months ago

  • Status changed from Under Review to In Progress

The "real" problem here is the option 'collapseAll' => 1 for the inline parent field which triggers the loop.

#12 Updated by Nicole Cordes 6 months ago

  • Status changed from In Progress to Under Review

#13 Updated by Gerrit Code Review 6 months ago

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

#14 Updated by Gerrit Code Review 6 months ago

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

#15 Updated by Gerrit Code Review 6 months ago

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

#16 Updated by Gerrit Code Review 6 months ago

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

#17 Updated by Gerrit Code Review 6 months ago

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

#18 Updated by Gerrit Code Review 6 months ago

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

#19 Updated by Gerrit Code Review 6 months ago

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

#20 Updated by Gerrit Code Review 6 months ago

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

#21 Updated by Gerrit Code Review 6 months ago

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

#22 Updated by Stanislas Rolland 6 months ago

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

Also available in: Atom PDF