Commit d4ba2f18 authored by Stefan Neufeind's avatar Stefan Neufeind
Browse files

[TASK] Only refresh pagetree on certain changes to pages

Pagetree only needs to refresh on changes to the
pages-table, and even there only when certain fields change.
checkSimilar in the DataHandler (enabled by default) already
compares current and new values to detect which fields really
change.

Change-Id: I324f4254634d4a758a3ecacecae076e17bdfcaab
Resolves: #64306
Releases: master
Reviewed-on: http://review.typo3.org/36034


Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Mathias Schreiber's avatarMathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber's avatarMathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
parent ccf93de5
......@@ -529,10 +529,6 @@ class EditDocumentController {
if (is_array($this->mirror)) {
$tce->setMirror($this->mirror);
}
// If pages are being edited, we set an instruction about updating the page tree after this operation.
if (isset($this->data['pages']) || $GLOBALS['BE_USER']->workspace != 0 && count($this->data)) {
BackendUtility::setUpdateSignal('updatePageTree');
}
// Checking referer / executing
$refInfo = parse_url(GeneralUtility::getIndpEnv('HTTP_REFERER'));
$httpHost = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY');
......@@ -544,6 +540,10 @@ class EditDocumentController {
$tce->process_uploads($_FILES);
$tce->process_datamap();
$tce->process_cmdmap();
// If pages are being edited, we set an instruction about updating the page tree after this operation.
if ($tce->pagetreeNeedsRefresh && (isset($this->data['pages']) || $GLOBALS['BE_USER']->workspace != 0 && count($this->data))) {
BackendUtility::setUpdateSignal('updatePageTree');
}
// If there was saved any new items, load them:
if (count($tce->substNEWwithIDs_table)) {
// save the expanded/collapsed states for new inline records, if any
......
......@@ -311,6 +311,20 @@ class DataHandler {
*/
public $errorLog = array();
/**
* Fields from the pages-table for which changes will trigger a pagetree refresh
*
* @var array
*/
public $pagetreeRefreshFieldsFromPages = array('pid', 'sorting', 'deleted', 'hidden', 'title', 'doktype', 'is_siteroot', 'fe_group', 'nav_hide', 'nav_title', 'module', 'starttime', 'endtime');
/**
* Indicates whether the pagetree needs a refresh because of important changes
*
* @var bool
*/
public $pagetreeNeedsRefresh = FALSE;
// *********************
// Internal Variables, do not touch.
......@@ -1054,6 +1068,9 @@ class DataHandler {
$id = $WSversion['uid'];
$recordAccess = TRUE;
} elseif ($this->BE_USER->workspaceAllowAutoCreation($table, $id, $theRealPid)) {
// new version of a record created in a workspace - so always refresh pagetree to indicate there is a change in the workspace
$this->pagetreeNeedsRefresh = TRUE;
$tce = GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
/** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
$tce->stripslashes_values = 0;
......@@ -1160,8 +1177,16 @@ class DataHandler {
// Kasper: Unsetting the fieldArray is dangerous; MM relations might be saved already and files could have been uploaded that are now "lost"
if (is_array($fieldArray)) {
if ($status == 'new') {
if ($table === 'pages') {
// for new pages always a refresh is needed
$this->pagetreeNeedsRefresh = TRUE;
}
// This creates a new version of the record with online placeholder and offline version
if ($createNewVersion) {
// new record created in a workspace - so always refresh pagetree to indicate there is a change in the workspace
$this->pagetreeNeedsRefresh = TRUE;
$newVersion_placeholderFieldArray['t3ver_label'] = 'INITIAL PLACEHOLDER';
// Setting placeholder state value for temporary record
$newVersion_placeholderFieldArray['t3ver_state'] = (string)new VersionState(VersionState::NEW_PLACEHOLDER);
......@@ -1190,6 +1215,14 @@ class DataHandler {
$this->insertDB($table, $id, $fieldArray, FALSE, $incomingFieldArray['uid']);
}
} else {
if ($table === 'pages') {
// only a certain number of fields needs to be checked for updates
// if $this->checkSimilar is TRUE, fields with unchanged values are already removed here
$fieldsToCheck = array_intersect($this->pagetreeRefreshFieldsFromPages, array_keys($fieldArray));
if (count($fieldsToCheck)) {
$this->pagetreeNeedsRefresh = TRUE;
}
}
$this->updateDB($table, $id, $fieldArray);
$this->placeholderShadowing($table, $id);
}
......@@ -2873,6 +2906,11 @@ class DataHandler {
foreach ($this->cmdmap[$table] as $id => $incomingCmdArray) {
$pasteUpdate = FALSE;
if (is_array($incomingCmdArray)) {
if ($table === 'pages') {
// for commands on pages do a pagetree-refresh
$this->pagetreeNeedsRefresh = TRUE;
}
// have found a command.
// Get command and value (notice, only one command is observed at a time!):
reset($incomingCmdArray);
......
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