Bug #84110

Files are deleted when a new record version is published

Added by Benedikt Huss almost 2 years ago. Updated 10 days ago.

Status:
Rejected
Priority:
Must have
Assignee:
-
Category:
Workspaces
Target version:
-
Start date:
2018-03-01
Due date:
% Done:

0%

TYPO3 Version:
7
PHP Version:
7.1
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

Lets assume we have a custom domain element with a column that is defined like this:

'sample_file' => array(
  'exclude' => 0,
  'label' => 'Sample File',
  'config' => array(
    'type' => 'group',
    'internal_type' => 'file',
    'uploadfolder' => 'uploads/tx_myextension/sampeFiles',
    'show_thumbs' => 1,
    'size' => 1,
    'allowed' => 'gif,jpg,jpeg',
    'disallowed' => '',
    'maxitems' => 1
  ),
),

When a record is created, the file can be uploaded and is stored in the upload folder. Now let’s assume this record is edited in a workspace (any field can be changed, but the sample file is unchanged). After the changes have been made, the record is published to the live workspace.

Unfortunately, as soon as the record is published, the file is deleted from the upload folder. This happens when versions for the published records are deleted. The code is located in \TYPO3\CMS\Core\DataHandling\DataHandler. In the function deleteRecord all fields that holds references to files are fetched, after that, all files are deleted without any further check.

Before a file is deleted, there should be a check if the file is not referenced by another record. Only if no other reference can be found, the file should really be deleted.

History

#1 Updated by Gerrit Code Review almost 2 years ago

  • Status changed from New 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/55982

#2 Updated by Oliver Hader almost 2 years ago

Thanks for your report and patch. In order to verify the behavior and bug fix I'd like to ask you for a complete step-by-step guide on how to reproduce the bug. Thanks in advance!

#3 Updated by Oliver Hader almost 2 years ago

  • Category set to Workspaces

#4 Updated by Benedikt Huss almost 2 years ago

Okay, I assume that there's an extension which contains a custom domain class with a column sample_file (see above).

Something like this:

return array(
    'ctrl' => array(
        'title' => 'My sample object',
        'label' => 'name',
        'tstamp' => 'tstamp',
        'crdate' => 'crdate',
        'searchFields' => 'uid,name',
        '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',
        ),
        'iconfile' => 'EXT:my_extension/Resources/Public/Icons/my_domain_model_icon.gif'
    ),
    'interface' => array(
        'showRecordFieldList' => 'hidden, name',
    ),
    'columns' => array(
        'hidden' => array(
            'exclude' => 1,
            'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
            'config' => array(
                'type' => 'check',
            ),
        ),
        'starttime' => array(
            'exclude' => 1,
            'l10n_mode' => 'mergeIfNotBlank',
            'label' => 'LLL:EXT:lang/locallang_general.php:LGL.starttime',
            'config' => array(
                'type' => 'input',
                'size' => '10',
                'max' => '20',
                'eval' => 'datetime',
                'checkbox' => '0',
                'default' => '0',
            ),
        ),
        'endtime' => array(
            'exclude' => 1,
            'l10n_mode' => 'mergeIfNotBlank',
            'label' => 'LLL:EXT:lang/locallang_general.php:LGL.endtime',
            'config' => array(
                'type' => 'input',
                'size' => '8',
                'max' => '20',
                'eval' => 'datetime',
                'checkbox' => '0',
                'default' => '0',
                'range' => array(
                    'upper' => mktime(0, 0, 0, 12, 31, date('Y') + 10),
                    'lower' => mktime(0, 0, 0, date('m') - 1, date('d'), date('Y'))
                ),
            ),
        ),
        'name' => array(
            'exclude' => 0,
            'label' => 'Name',
            'config' => array(
                'type' => 'input',
                'size' => 30,
                'eval' => 'trim'
            ),
        ),
        'sample_file' => array(
            'exclude' => 0,
            'label' => 'My sample file',
            'config' => array(
                'type' => 'group',
                'internal_type' => 'file',
                'uploadfolder' => 'uploads/tx_myextension/samples',
                'show_thumbs' => 1,
                'size' => 1,
                'allowed' => 'gif,jpg,jpeg',
                'disallowed' => '',
                'maxitems' => 1
            ),
        ),
    ),
);

  1. Add a record for this domain class to a page or a folder in the live workspace. A file should also be uploaded. Check that the file exists in the upload folder.
  2. Create another workspace
  3. Edit the existing record in another workspace
  4. Publish the changes to the live workspace

As soon as other record versions are deleted when the record is published, the file is deleted from the upload folder.

#5 Updated by Gerrit Code Review over 1 year 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/55982

#6 Updated by Gerrit Code Review about 1 year 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/55982

#7 Updated by Gerrit Code Review about 1 year 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/55982

#8 Updated by Susanne Moog 10 days ago

  • Status changed from Under Review to Rejected

See comment in the patch, I'm closing the issue for now. If somebody is interested in fixing that for older versions, feel free to add a new issue.

Also available in: Atom PDF