diff --git a/typo3/sysext/version/Classes/Dependency/DependencyEntityFactory.php b/typo3/sysext/version/Classes/Dependency/DependencyEntityFactory.php index b42ad36..f31ba83 100644 --- a/typo3/sysext/version/Classes/Dependency/DependencyEntityFactory.php +++ b/typo3/sysext/version/Classes/Dependency/DependencyEntityFactory.php @@ -30,6 +30,11 @@ class DependencyEntityFactory { protected $references = array(); /** + * @var array + */ + protected $tables = array(); + + /** * Gets and registers a new element. * * @param string $table @@ -76,7 +81,27 @@ class DependencyEntityFactory { * @see getReference */ public function getReferencedElement($table, $id, $field, array $data = array(), \TYPO3\CMS\Version\Dependency\DependencyResolver $dependency) { - return $this->getReference($this->getElement($table, $id, $data, $dependency), $field); + + if (empty($this->tables)) { + $tables = $GLOBALS['TYPO3_DB']->admin_get_tables(); + $this->tables = array_keys($tables); + } + + if (in_array($table, $this->tables) && $this->isVersionable($table)) { + return $this->getReference($this->getElement($table, $id, $data, $dependency), $field); + } else { + return NULL; + } } + /** + * Check if versioning is enabled . + * + * @see http://docs.typo3.org/typo3cms/TCAReference/Reference/Ctrl/Index.html#versioningws + * + * @return boolean + */ + protected function isVersionable($table) { + return (bool)$GLOBALS['TCA'][$table]['ctrl']['versioningWS']; + } } diff --git a/typo3/sysext/version/Classes/Dependency/ElementEntity.php b/typo3/sysext/version/Classes/Dependency/ElementEntity.php index a13d88f..88c32c2 100644 --- a/typo3/sysext/version/Classes/Dependency/ElementEntity.php +++ b/typo3/sysext/version/Classes/Dependency/ElementEntity.php @@ -216,13 +216,15 @@ class ElementEntity { $arguments = array('table' => $row['ref_table'], 'id' => $row['ref_uid'], 'field' => $row['field'], 'scope' => self::REFERENCES_ChildOf); $callbackResponse = $this->dependency->executeEventCallback(self::EVENT_CreateChildReference, $this, $arguments); if ($callbackResponse !== self::RESPONSE_Skip) { - $this->children[] = $this->getDependency()->getFactory()->getReferencedElement( + $child = $this->getDependency()->getFactory()->getReferencedElement( $row['ref_table'], $row['ref_uid'], $row['field'], array(), $this->getDependency() ); + if (!empty($child)) + $this->children[] = $child; } } } @@ -246,17 +248,22 @@ class ElementEntity { $arguments = array('table' => $row['tablename'], 'id' => $row['recuid'], 'field' => $row['field'], 'scope' => self::REFERENCES_ParentOf); $callbackResponse = $this->dependency->executeEventCallback(self::EVENT_CreateParentReference, $this, $arguments); if ($callbackResponse !== self::RESPONSE_Skip) { - $this->parents[] = $this->getDependency()->getFactory()->getReferencedElement( + $parent = $this->getDependency()->getFactory()->getReferencedElement( $row['tablename'], $row['recuid'], $row['field'], array(), $this->getDependency() ); + // NULL nicht mit hinzufügen + if(NULL !== $parent) { + $this->parents[] = $parent; + } } } } } + return $this->parents; } @@ -283,6 +290,7 @@ class ElementEntity { $this->outerMostParent = FALSE; /** @var $parent \TYPO3\CMS\Version\Dependency\ReferenceEntity */ foreach ($parents as $parent) { + $outerMostParent = $parent->getElement()->getOuterMostParent(); if ($outerMostParent instanceof \TYPO3\CMS\Version\Dependency\ElementEntity) { $this->outerMostParent = $outerMostParent;