Bug #80426

Creating a FlexForm section causes exception in ajax request (none admin user)

Added by Benjamin no-lastname-given over 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
Start date:
2017-03-23
Due date:
% Done:

100%

TYPO3 Version:
8
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

I can´t add a new flexform section because the ajax request that´s being made gets a typo3 exception.

IMPORTANT:
This does not happen with a admin account.
Only a default be-user triggers this error. (In my case this be-user is not limited to any languages)

The problem is, that the $result form DatabaseUserPermissionCheck::addData is not correctly filled.

I made a quick&dirty workaround here: https://github.com/BenjaminBeck/TYPO3.CMS/commit/3fa93f055973aaf06b6d3f741a0b6c9a3df639ae

example_0.1.0_201703271505.zip (4.39 KB) Marcus Schwemer, 2017-03-27 15:08


Related issues

Related to TYPO3 Core - Task #80100: Bypass fetch of database record if already loaded Closed 2017-03-02
Related to TYPO3 Core - Bug #80473: Do not bypass fetch of database record if tableName is tt_content Closed 2017-03-27
Related to TYPO3 Core - Bug #80825: FlexForm Sections don't get saved before the parent record was stored to the DB Closed 2017-04-12

Associated revisions

Revision ff0b0832 (diff)
Added by Xavier Perseguers over 2 years ago

[BUGFIX] Remove partial row initialization in FlexForm sections

Since #80100, database row should not be partially initialized before
calling DatabaseEditRow form data provider. This changes removes the
partial row initialization with only the corresponding "uid" which is
not needed anyway.

Resolves: #80473
Resolves: #80426
Related: #80100
Releases: master
Change-Id: Iadf180a0c52e36989afcb2a59ff7746a60e81bfb
Reviewed-on: https://review.typo3.org/52174
Tested-by: TYPO3com <>
Reviewed-by: Christian Kuhn <>
Tested-by: Christian Kuhn <>
Reviewed-by: Thomas Hohn <>
Reviewed-by: Frank Naegler <>
Tested-by: Frank Naegler <>
Reviewed-by: Jan Helke <>

History

#1 Updated by Benjamin no-lastname-given over 2 years ago

  • Category changed from Frontend to FormEngine aka TCEforms

#2 Updated by Wouter Wolters over 2 years ago

  • Status changed from New to Needs Feedback

Could provide us with some more information what the exact error is you get?
Is it possible to attach a test extension that can reproduce this error on current master?

#3 Updated by Marcus Schwemer over 2 years ago

Sounds like the same what we are experiencing currently.

We have a content element where editors can add one or more items to a list via a flexform.

If editors create a new ce, they can add as many items as they want. If the save it and then try to add a new item, it results in an error 500. Looking at the console, reveils an error 500. The exception message is

    No content edit permission for user 2 on page root node

This is "right", because the user does not have permission to edit on the root page. On the other hand, this is the explanation, why this does not "harm" admin users. They are allowed to edit records on uid 0.

The ajax request in both cases (new ce and saved ce) is:

http://t3trunk/typo3/index.php?ajaxID=%2Fajax%2Frecord%2Fflex%2Fcontaineradd&ajaxToken=628ecdf44b955861e2ba1b9c0ee2a98478cbfed6

I'm using the current master with php 7.0

#4 Updated by Marcus Schwemer over 2 years ago

Here is a basic example extension, which contains an additional CE building a link list. Only the backend stuff is included ...

#6 Updated by Alex Kellner over 2 years ago

Our current workarround to get this issue done for two new content elements is to add an own FormDataProvider. Thx to Markus Sommer for the quick fix.
Maybe someone else needs this.

ext_tables.php of the template extension:

$class = \In2code\In2template\Backend\FormDataProvider\FixEditorPermissions::class;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][$class] = [
    'before' => [
        \TYPO3\CMS\Backend\Form\FormDataProvider\ReturnUrl::class,
    ]
];

FixEditorPermissons.php:

<?php
declare(strict_types = 1);
namespace In2code\In2template\Backend\FormDataProvider;

use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;

/**
 * Resolve return Url if not set otherwise.
 * This fixes FlexForm with inline elements. Editors can not add new itemsets.
 * An error 500 is thrown in browser console that's not allowed to add new items to page with uid=0.
 */
class FixEditorPermissions implements FormDataProviderInterface
{

    /**
     * @param array $result
     * @return array
     */
    public function addData(array $result)
    {
        if ($result['tableName'] === 'tt_content') {
            $result['databaseRow'] = BackendUtility::getRecord($result['tableName'], $result['databaseRowUid']);
        }
        return $result;
    }
}

#7 Updated by Christian Kuhn over 2 years ago

I'm able to reproduce the issue with the extension and will review the proposed pending fix now.

#8 Updated by Gerrit Code Review over 2 years ago

  • Status changed from Needs Feedback to Under Review

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/52174

#9 Updated by Xavier Perseguers over 2 years ago

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

#10 Updated by Daniel Goerz over 2 years ago

  • Related to Bug #80825: FlexForm Sections don't get saved before the parent record was stored to the DB added

#11 Updated by Riccardo De Contardi almost 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF