Bug #11833 ยป forge_11833.patch

Oliver Hader, 2011-01-01 20:13

View differences:

class.tx_version_tcemain.php (Arbeitskopie)
50 50
	 */
51 51
	protected $generalComment = '';
52 52

  
53
	/**
54
	 * Contains remapped IDs.
55
	 *
56
	 * @var array
57
	 */
58
	protected $remappedIds = array();
59

  
53 60
	/****************************
54 61
	 *****  Cmdmap  Hooks  ******
55 62
	 ****************************/
......
144 151

  
145 152
			// Reset notification array
146 153
		$this->notificationEmailInfo = array();
154
			// Reset remapped IDs
155
		$this->remappedIds = array();
147 156
	}
148 157

  
149 158

  
......
871 880
										}
872 881

  
873 882
										if (!count($sqlErrors)) {
883
												// Register swapped ids for later remapping:
884
											$this->remappedIds[$table][$id] =$swapWith;
885
											$this->remappedIds[$table][$swapWith] = $id;
874 886

  
875 887
												// If a moving operation took place...:
876 888
											if ($movePlhID) {
......
997 1009
			$dbAnalysisSwap->setUpdateReferenceIndex(FALSE);
998 1010
			$dbAnalysisSwap->start('', $conf['foreign_table'], '', $swapVersion['uid'], $table, $conf);
999 1011
				// Update relations for both (workspace/versioning) sites:
1000
			$dbAnalysisCur->writeForeignField($conf, $curVersion['uid'], $swapVersion['uid']);
1001
			$dbAnalysisSwap->writeForeignField($conf, $swapVersion['uid'], $curVersion['uid']);
1002 1012

  
1013
			if (count($dbAnalysisCur->itemArray)) {
1014
				$dbAnalysisCur->writeForeignField($conf, $curVersion['uid'], $swapVersion['uid']);
1015
				$tcemainObj->addRemapAction(
1016
					$table, $curVersion['uid'],
1017
					array($this, 'writeRemappedForeignField'),
1018
					array($dbAnalysisCur, $conf, $swapVersion['uid'])
1019
				);
1020
			}
1021

  
1022
			if (count($dbAnalysisSwap->itemArray)) {
1023
				$dbAnalysisSwap->writeForeignField($conf, $swapVersion['uid'], $curVersion['uid']);
1024
				$tcemainObj->addRemapAction(
1025
					$table, $curVersion['uid'],
1026
					array($this, 'writeRemappedForeignField'),
1027
					array($dbAnalysisSwap, $conf, $curVersion['uid'])
1028
				);
1029
			}
1030

  
1003 1031
			$items = array_merge($dbAnalysisCur->itemArray, $dbAnalysisSwap->itemArray);
1004 1032
			foreach ($items as $item) {
1005 1033
				$tcemainObj->addRemapStackRefIndex($item['table'], $item['id']);
......
1014 1042
		}
1015 1043
	}
1016 1044

  
1045
	/**
1046
	 * Writes remapped foreign field (IRRE).
1047
	 *
1048
	 * @param t3lib_loadDBGroup $dbAnalysis Instance that holds the sorting order of child records
1049
	 * @param array $configuration The TCA field configuration
1050
	 * @param integer $parentId The uid of the parent record
1051
	 * @return void
1052
	 */
1053
	public function writeRemappedForeignField(t3lib_loadDBGroup $dbAnalysis, array $configuration, $parentId) {
1054
		foreach ($dbAnalysis->itemArray as &$item) {
1055
			if (isset($this->remappedIds[$item['table']][$item['id']])) {
1056
				$item['id'] = $this->remappedIds[$item['table']][$item['id']];
1057
			}
1058
		}
1017 1059

  
1060
		$dbAnalysis->writeForeignField($configuration, $parentId);
1061
	}
1018 1062

  
1063

  
1064

  
1019 1065
	/**
1020 1066
	 * Release version from this workspace (and into "Live" workspace but as an offline version).
1021 1067
	 *
    (1-1/1)