Skip to content

Commit

Permalink
[BUGFIX] Filter deleted workspace placeholders from FAL records (Flui…
Browse files Browse the repository at this point in the history
…dTYPO3#1061)

This change skips resolving of any file references or file objects which are in a workspace overlay with a state of DELETED. Such files / file references will no longer be shown by (record based) FAL ViewHelpers in general.

Close: FluidTYPO3#896
  • Loading branch information
NamelessCoder authored and bjo3rnf committed Jun 24, 2016
1 parent 9c739c7 commit efa01ee
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Classes/ViewHelpers/Resource/Record/FalViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
use TYPO3\CMS\Core\Versioning\VersionState;

/**
* Resolve FAL relations and return file records.
Expand Down Expand Up @@ -101,9 +102,9 @@ public function getResources($record)
$sqlRecordUid = $record[$this->idField];
}

$images = [];
$fileReferences = [];
if (empty($GLOBALS['TSFE']->sys_page) === false) {
$images = $this->getFileReferences($this->getTable(), $this->getField(), $sqlRecordUid);
$fileReferences = $this->getFileReferences($this->getTable(), $this->getField(), $sqlRecordUid);
} else {
if ($GLOBALS['BE_USER']->workspaceRec['uid']) {
$versionWhere = 'AND sys_file_reference.deleted=0 AND (sys_file_reference.t3ver_wsid=0 OR ' .
Expand All @@ -127,13 +128,13 @@ public function getResources($record)
);
if (empty($references) === false) {
$referenceUids = array_keys($references);
$images = [];
$fileReferences = [];
if (empty($referenceUids) === false) {
foreach ($referenceUids as $referenceUid) {
try {
// Just passing the reference uid, the factory is doing workspace
// overlays automatically depending on the current environment
$images[] = $this->resourceFactory->getFileReferenceObject($referenceUid);
$fileReferences[] = $this->resourceFactory->getFileReferenceObject($referenceUid);
} catch (ResourceDoesNotExistException $exception) {
// No handling, just omit the invalid reference uid
continue;
Expand All @@ -143,8 +144,11 @@ public function getResources($record)
}
}
$resources = [];
foreach ($images as $file) {
$resources[] = $this->getResource($file);
foreach ($fileReferences as $file) {
// Exclude workspace deleted files references
if ($file->getProperty('t3ver_state') !== VersionState::DELETE_PLACEHOLDER) {
$resources[] = $this->getResource($file);
}
}
return $resources;
}
Expand Down

0 comments on commit efa01ee

Please sign in to comment.