Commit 4dd99fee authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[!!!][TASK] Remove static file edit magic

Configuring RTE fields TCA in defaultExtras section with static_write
enabled the DataHandler to write content to specific sections of files
in a specific directory.

This feature is documented and existed for a long time, but is not used
in the wild. Searching for keywords just revealed a very outdated
demo page, the according core source and documentation. No extension
or real live use case was found and even a call for feedback on this
by Benni half a year ago got no answers.

The patch removes this feature without substitution and improves
DataHandler performance as a nice side effect.

Resolves: #63818
Resolves: #63668
Releases: master
Change-Id: I5532ba1565370baeb03ce074c8ab8036a0936d5b
Reviewed-on: http://review.typo3.org/35369


Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: default avatarMarkus Klein <klein.t3@reelworx.at>
Reviewed-by: default avatarHelmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Benni Mack's avatarBenjamin Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 0074a9d0
......@@ -268,12 +268,6 @@ class DataPreprocessor {
$data = $this->renderRecord_SW($data, $fieldConfig, $TSconfig, $table, $row, $field);
$totalRecordContent[$field] = $data;
}
// Further processing may apply for each field in the record depending on the settings in the "types" configuration (the list of fields to currently display for a record in TCEforms).
// For instance this could be processing instructions for the Rich Text Editor.
$types_fieldConfig = BackendUtility::getTCAtypes($table, $totalRecordContent);
if (is_array($types_fieldConfig)) {
$totalRecordContent = $this->renderRecord_typesProc($totalRecordContent, $types_fieldConfig, $tscPID, $table, $pid);
}
// Register items, mostly for external use (overriding the regItem() function)
foreach ($totalRecordContent as $field => $data) {
$this->regItem($table, $id, $field, $data);
......@@ -471,22 +465,10 @@ class DataPreprocessor {
* @param int $pid PID value
* @return array The processed version of $totalRecordContent
* @access private
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
*/
public function renderRecord_typesProc($totalRecordContent, $types_fieldConfig, $tscPID, $table, $pid) {
foreach ($types_fieldConfig as $vconf) {
// Find file to write to, if configured:
$eFile = \TYPO3\CMS\Core\Html\RteHtmlParser::evalWriteFile($vconf['spec']['static_write'], $totalRecordContent);
// Write file configuration:
if (is_array($eFile)) {
if ($eFile['loadFromFileField'] && $totalRecordContent[$eFile['loadFromFileField']]) {
// Read the external file, and insert the content between the ###TYPO3_STATICFILE_EDIT### markers:
$SW_fileContent = GeneralUtility::getUrl($eFile['editFile']);
$parseHTML = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Html\RteHtmlParser::class);
$parseHTML->init('', '');
$totalRecordContent[$vconf['field']] = $parseHTML->getSubpart($SW_fileContent, $eFile['markerField'] && trim($totalRecordContent[$eFile['markerField']]) ? trim($totalRecordContent[$eFile['markerField']]) : '###TYPO3_STATICFILE_EDIT###');
}
}
}
GeneralUtility::logDeprecatedFunction();
return $totalRecordContent;
}
......
......@@ -89,9 +89,6 @@ class TextElement extends AbstractFormElement {
if (!$rteSetupConfiguration['disabled']) {
if (!$this->formEngine->disableRTE) {
$this->formEngine->RTEcounter++;
// Find alternative relative path for RTE images/links:
$evalWriteFile = RteHtmlParser::evalWriteFile($specialConfiguration['static_write'], $row);
$rteRelativePath = is_array($evalWriteFile) ? dirname($evalWriteFile['relEditFile']) : '';
// Get RTE object, draw form and set flag:
$rteObject = BackendUtility::RTEgetObj();
$item = $rteObject->drawRTE(
......@@ -103,7 +100,7 @@ class TextElement extends AbstractFormElement {
$specialConfiguration,
$rteSetupConfiguration,
$rteTcaTypeValue,
$rteRelativePath,
'',
$tsConfigPid
);
......
......@@ -1417,9 +1417,6 @@ class DataHandler {
$theTypeString = BackendUtility::getTCAtypeValue($table, $currentRecord);
if (is_array($types_fieldConfig)) {
foreach ($types_fieldConfig as $vconf) {
// Write file configuration:
// inserted array_merge($currentRecord,$fieldArray) 170502
$eFile = \TYPO3\CMS\Core\Html\RteHtmlParser::evalWriteFile($vconf['spec']['static_write'], array_merge($currentRecord, $fieldArray));
// RTE transformations:
if (!$this->dontProcessTransformations) {
if (isset($fieldArray[$vconf['field']])) {
......@@ -1428,12 +1425,10 @@ class DataHandler {
case 'RTE':
$RTEsetup = $this->BE_USER->getTSConfig('RTE', BackendUtility::getPagesTSconfig($tscPID));
$thisConfig = BackendUtility::RTEsetup($RTEsetup['properties'], $table, $vconf['field'], $theTypeString);
// Set alternative relative path for RTE images/links:
$RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
// Get RTE object, draw form and set flag:
$RTEobj = BackendUtility::RTEgetObj();
if (is_object($RTEobj)) {
$fieldArray[$vconf['field']] = $RTEobj->transformContent('db', $fieldArray[$vconf['field']], $table, $vconf['field'], $currentRecord, $vconf['spec'], $thisConfig, $RTErelPath, $currentRecord['pid']);
$fieldArray[$vconf['field']] = $RTEobj->transformContent('db', $fieldArray[$vconf['field']], $table, $vconf['field'], $currentRecord, $vconf['spec'], $thisConfig, '', $currentRecord['pid']);
} else {
debug('NO RTE OBJECT FOUND!');
}
......@@ -1441,27 +1436,6 @@ class DataHandler {
}
}
}
// Write file configuration:
if (is_array($eFile)) {
$mixedRec = array_merge($currentRecord, $fieldArray);
$SW_fileContent = GeneralUtility::getUrl($eFile['editFile']);
$parseHTML = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Html\RteHtmlParser::class);
/** @var $parseHTML \TYPO3\CMS\Core\Html\RteHtmlParser */
$parseHTML->init('', '');
$eFileMarker = $eFile['markerField'] && trim($mixedRec[$eFile['markerField']]) ? trim($mixedRec[$eFile['markerField']]) : '###TYPO3_STATICFILE_EDIT###';
// Must replace the marker if present in content!
$insertContent = str_replace($eFileMarker, '', $mixedRec[$eFile['contentField']]);
$SW_fileNewContent = $parseHTML->substituteSubpart($SW_fileContent, $eFileMarker, LF . $insertContent . LF, 1, 1);
GeneralUtility::writeFile($eFile['editFile'], $SW_fileNewContent);
// Write status:
if (!strstr($id, 'NEW') && $eFile['statusField']) {
$this->databaseConnection->exec_UPDATEquery($table, 'uid=' . (int)$id, array(
$eFile['statusField'] => $eFile['relEditFile'] . ' updated ' . date('d-m-Y H:i:s') . ', bytes ' . strlen($mixedRec[$eFile['contentField']])
));
}
} elseif ($eFile && is_string($eFile)) {
$this->log($table, $id, 2, 0, 1, 'Write-file error: \'%s\'', 13, array($eFile), $realPid);
}
}
}
// Return fieldArray
......
......@@ -125,6 +125,7 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser {
*
* @param string $path The relative path from PATH_site to the place where the file being edited is. Eg. "fileadmin/static".
* @return void There is no output, it is set in internal variables. With the above example of "fileadmin/static" as input this will yield ->relPath to be "fileadmin/static/" and ->relBackPath to be "../../
* @TODO: Check if relPath and relBackPath are used for anything useful after removal of "static file edit" with #63818
*/
public function setRelPath($path) {
$path = trim($path);
......@@ -149,36 +150,10 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser {
* @param array $pArr Parameters for the current field as found in types-config
* @param array $currentRecord Current record we are editing.
* @return mixed On success an array with various information is returned, otherwise a string with an error message
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
*/
static public function evalWriteFile($pArr, $currentRecord) {
// Write file configuration:
if (is_array($pArr)) {
if ($GLOBALS['TYPO3_CONF_VARS']['BE']['staticFileEditPath'] && substr($GLOBALS['TYPO3_CONF_VARS']['BE']['staticFileEditPath'], -1) == '/' && @is_dir((PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['staticFileEditPath']))) {
$SW_p = $pArr['parameters'];
$SW_editFileField = trim($SW_p[0]);
$SW_editFile = $currentRecord[$SW_editFileField];
if ($SW_editFileField && $SW_editFile && GeneralUtility::validPathStr($SW_editFile)) {
$SW_relpath = $GLOBALS['TYPO3_CONF_VARS']['BE']['staticFileEditPath'] . $SW_editFile;
$SW_editFile = PATH_site . $SW_relpath;
if (@is_file($SW_editFile)) {
return array(
'editFile' => $SW_editFile,
'relEditFile' => $SW_relpath,
'contentField' => trim($SW_p[1]),
'markerField' => trim($SW_p[2]),
'loadFromFileField' => trim($SW_p[3]),
'statusField' => trim($SW_p[4])
);
} else {
return 'ERROR: Editfile \'' . $SW_relpath . '\' did not exist';
}
} else {
return 'ERROR: Edit file name could not be found or was bad.';
}
} else {
return 'ERROR: staticFileEditPath was not set, not set correctly or did not exist!';
}
}
GeneralUtility::logDeprecatedFunction();
}
/**********************************************
......
......@@ -280,7 +280,6 @@ return array(
'RTEenabled' => TRUE, // Boolean: If set, the Rich Text editor will be an option in the backend. Notice that the editor must be enabled per-user and options are configurable. See admin guide.
'RTE_imageStorageDir' => 'uploads/', // Default storage directory for Rich Text Editor files
'RTE_reg' => array(), // Contains arrays of possible RTEs available (keys=extKey, values=cfg-array). Each array contains a key, "objRef", which contains a user function call with prefixed script path and instanciating a persistent global object. This can report back if browser requirements are OK, draw the RTE and do the transformations needed.
'staticFileEditPath' => 'fileadmin/static/', // Path to directory with static files for editing (see table sys_staticfiles_edit). Relative to PATH_site.
'lockRootPath' => '', // This path is used to evaluate if paths outside of PATH_site should be allowed. Ending slash required!
'userHomePath' => '', // Combined folder identifier of the directory where TYPO3 backend-users have their home-dirs. A combined folder identifier looks like this: [storageUid]:[folderIdentifier]. Eg. '2:users/'. A home for backend user 2 would be: '2:users/2/'. Ending slash required!
'groupHomePath' => '', // Combined folder identifier of the directory where TYPO3 backend-groups have their home-dirs. A combined folder identifier looks like this: [storageUid]:[folderIdentifier]. Eg. '2:groups/'. A home for backend group 1 would be: '2:groups/1/'. Ending slash required!
......
=========================================================
Breaking: #63818 - Removed Static file edit functionality
=========================================================
Description
===========
A special TCA configuration enabled RTE fields to write its content to sections within files. The configuration
was done in "defaultExtras" array, "static_write" section and documented in
TCA reference->AdditionalFeatures->SpecialConfigurationOptions.
This functionality is removed without substitution.
Impact
======
Content of RTE fields will no longer be written to files.
Affected installations
======================
In the unlikely case this feature was used by anyone its usage can be located by searching for "static_write"
keyword in TCA configuration.
Migration
=========
Move this logic elsewhere, eg. use hooks in DataHandler to write out DB content.
\ No newline at end of file
......@@ -66,6 +66,8 @@ class SilentConfigurationUpgradeService {
'INSTALL/wizardDone/TYPO3\\CMS\\Install\\Updates\\TceformsUpdateWizard',
'INSTALL/wizardDone/TYPO3\\CMS\\Install\\Updates\\TtContentUploadsUpdateWizard',
'INSTALL/wizardDone/TYPO3\\CMS\\Install\\Updates\\TruncateSysFileProcessedFileTable',
// #63818
'BE/staticFileEditPath',
);
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment