Bug #66572 » patch-66572.diff

Kay no-lastname-given, 2015-05-11 14:46

View differences:

typo3/sysext/version/Classes/Dependency/DependencyEntityFactory.php
30 30
	protected $references = array();
31 31

  
32 32
	/**
33
	 * @var array
34
	 */
35
	protected $tables = array();
36

  
37
	/**
33 38
	 * Gets and registers a new element.
34 39
	 *
35 40
	 * @param string $table
......
76 81
	 * @see getReference
77 82
	 */
78 83
	public function getReferencedElement($table, $id, $field, array $data = array(), \TYPO3\CMS\Version\Dependency\DependencyResolver $dependency) {
79
		return $this->getReference($this->getElement($table, $id, $data, $dependency), $field);
84

  
85
		if (empty($this->tables)) {
86
			$tables = $GLOBALS['TYPO3_DB']->admin_get_tables();
87
			$this->tables = array_keys($tables);
88
		}
89

  
90
		if (in_array($table, $this->tables) && $this->isVersionable($table)) {
91
			return $this->getReference($this->getElement($table, $id, $data, $dependency), $field);
92
		} else {
93
			return NULL;
94
		}
80 95
	}
81 96

  
97
	/**
98
	 * Check if versioning is enabled .
99
     *
100
     * @see http://docs.typo3.org/typo3cms/TCAReference/Reference/Ctrl/Index.html#versioningws
101
	 *
102
	 * @return boolean
103
	 */
104
	protected function isVersionable($table) {
105
        return (bool)$GLOBALS['TCA'][$table]['ctrl']['versioningWS'];
106
	}
82 107
}
typo3/sysext/version/Classes/Dependency/ElementEntity.php
216 216
					$arguments = array('table' => $row['ref_table'], 'id' => $row['ref_uid'], 'field' => $row['field'], 'scope' => self::REFERENCES_ChildOf);
217 217
					$callbackResponse = $this->dependency->executeEventCallback(self::EVENT_CreateChildReference, $this, $arguments);
218 218
					if ($callbackResponse !== self::RESPONSE_Skip) {
219
						$this->children[] = $this->getDependency()->getFactory()->getReferencedElement(
219
						$child = $this->getDependency()->getFactory()->getReferencedElement(
220 220
							$row['ref_table'],
221 221
							$row['ref_uid'],
222 222
							$row['field'],
223 223
							array(),
224 224
							$this->getDependency()
225 225
						);
226
						if (!empty($child))
227
							$this->children[] = $child;
226 228
					}
227 229
				}
228 230
			}
......
246 248
					$arguments = array('table' => $row['tablename'], 'id' => $row['recuid'], 'field' => $row['field'], 'scope' => self::REFERENCES_ParentOf);
247 249
					$callbackResponse = $this->dependency->executeEventCallback(self::EVENT_CreateParentReference, $this, $arguments);
248 250
					if ($callbackResponse !== self::RESPONSE_Skip) {
249
						$this->parents[] = $this->getDependency()->getFactory()->getReferencedElement(
251
						$parent = $this->getDependency()->getFactory()->getReferencedElement(
250 252
							$row['tablename'],
251 253
							$row['recuid'],
252 254
							$row['field'],
253 255
							array(),
254 256
							$this->getDependency()
255 257
						);
258
                        // NULL nicht mit hinzufügen
259
                        if(NULL !== $parent) {
260
                            $this->parents[] = $parent;
261
                        }
256 262
					}
257 263
				}
258 264
			}
259 265
		}
266

  
260 267
		return $this->parents;
261 268
	}
262 269

  
......
283 290
				$this->outerMostParent = FALSE;
284 291
				/** @var $parent \TYPO3\CMS\Version\Dependency\ReferenceEntity */
285 292
				foreach ($parents as $parent) {
293

  
286 294
					$outerMostParent = $parent->getElement()->getOuterMostParent();
287 295
					if ($outerMostParent instanceof \TYPO3\CMS\Version\Dependency\ElementEntity) {
288 296
						$this->outerMostParent = $outerMostParent;
(2-2/2)