[TYPO3-dev] Patch for abandoned extension jfmulticontent: Fix impexp bug

pcworld 0188801 at googlemail.com
Wed Dec 23 01:18:45 CET 2015


jfmulticontent is marked as an abandoned extension (its author is
"abandoned_extensions").
Some time ago it was suggested that people could submit submit patches
for abandoned extensions to some mailing list [0]; however I don't
whether this actually became practice.
Anyway, I'm submitting a patch here for jfmulticontent 2.9.9 that fixes
a serious bug; whoever can maintain abandoned extensions, feel free to
incorporate this patch (or an improvement thereof) into some future
version of jfmulticontent.

The bug is that when importing a T3D which contains pages with at least
one jfmulticontent content element using the impexp module, a hook in
jfmulticontent sets all content elements' colPos to jfmulticontent's
magic colPos, which is obviously wrong.
My solution is to disable the hook when run in the impexp module.
I don't know whether the bug (explained in a little more detail in the
patch itself) can arise in other situations/modules too; if so, a more
enhanced blacklist or refactoring would be appropriate.
I have only tried the patch on TYPO3 6.2. I don't know whether the
module check works on earlier versions of TYPO3 (the extension claims to
support TYPO3 4.3.0 to 6.2.99).

[0]: https://forum.typo3.org/index.php/t/202209/

--- lib/class.tx_jfmulticontent_tcemain.php
+++ lib/class.tx_jfmulticontent_tcemain.php
@@ -41,21 +41,27 @@
  	 *
  	 * @param array $incomingFieldArray
  	 * @param string $table
-	 * @param integer $id
+	 * @param mixed $id
  	 * @param t3lib_TCEmain $pObj
  	 * @see tx_templavoila_tcemain::processDatamap_afterDatabaseOperations()
  	 */
  	public function processDatamap_preProcessFieldArray(array 
&$incomingFieldArray, $table, $id, t3lib_TCEmain &$pObj) {
-		if ($incomingFieldArray['list_type'] != 'jfmulticontent_pi1') {
-			if (is_array($pObj->datamap['tt_content'])) {
-				foreach ($pObj->datamap['tt_content'] as $key => $val) {
-					if ($val['list_type'] == 'jfmulticontent_pi1' && 
$val['tx_jfmulticontent_view'] == 'irre') {
-						// Change the colPos of the IRRE tt_content values
-						$confArr = 
unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['jfmulticontent']);
-						$incomingFieldArray['colPos'] = $confArr['colPosOfIrreContent'];
-						// Workaround for templavoila
-						if (t3lib_extMgm::isLoaded('templavoila')) {
-						 
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tx_templavoila_tcemain']['doNotInsertElementRefsToPage'] 
= TRUE;
+		// Do not run this hook when importing a T3D. $pObj->datamap might 
then contain multiple content elements;
+		// the below code would then change colPos on any such content 
element to jfmulticontent's magic number,
+		// even if the content element is not part of a jfmulticontent 
content element.
+		// Note that there might still be similar bugs outside of the impexp 
module.
+		if (t3lib_div::_GET('M') !== 'xMOD_tximpexp') {
+			if ($incomingFieldArray['list_type'] != 'jfmulticontent_pi1') {
+				if (is_array($pObj->datamap['tt_content'])) {
+					foreach ($pObj->datamap['tt_content'] as $key => $val) {
+						if ($val['list_type'] == 'jfmulticontent_pi1' && 
$val['tx_jfmulticontent_view'] == 'irre') {
+							// Change the colPos of the IRRE tt_content values
+							$confArr = 
unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['jfmulticontent']);
+							$incomingFieldArray['colPos'] = $confArr['colPosOfIrreContent'];
+							// Workaround for templavoila
+							if (t3lib_extMgm::isLoaded('templavoila')) {
+							 
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tx_templavoila_tcemain']['doNotInsertElementRefsToPage'] 
= TRUE;
+							}
  						}
  					}
  				}



More information about the TYPO3-dev mailing list