Project

General

Profile

Actions

Bug #80426

closed

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

Added by Benjamin no-lastname-given about 7 years ago. Updated over 6 years ago.

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

100%

Estimated time:
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


Files

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

Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Task #80100: Bypass fetch of database record if already loadedClosedXavier Perseguers2017-03-02

Actions
Related to TYPO3 Core - Bug #80473: Do not bypass fetch of database record if tableName is tt_contentClosedFaton Haliti2017-03-27

Actions
Related to TYPO3 Core - Bug #80825: FlexForm Sections don't get saved before the parent record was stored to the DBClosedChristian Kuhn2017-04-12

Actions
Actions #1

Updated by Benjamin no-lastname-given about 7 years ago

  • Category changed from Frontend to FormEngine aka TCEforms
Actions #2

Updated by Wouter Wolters about 7 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?

Actions #3

Updated by Marcus Schwemer about 7 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

Actions #4

Updated by Marcus Schwemer about 7 years ago

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

Actions #5

Updated by Markus Sommer about 7 years ago

Actions #6

Updated by Alex Kellner about 7 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;
    }
}

Actions #7

Updated by Christian Kuhn about 7 years ago

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

Actions #8

Updated by Gerrit Code Review about 7 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

Actions #9

Updated by Xavier Perseguers about 7 years ago

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

Updated by Daniel Goerz about 7 years ago

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

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF