Issue Bug Closed

#19974Empty subpart markers ignored

Robert Lockerbie 02/06/09, 02:31 updated 10/02/18, 12:27

Description

When using a template with an empty subpart (), that subpart will be ignored and hence no content will be inserted. This usually shows up when using automaketemplate with an empty element (
) which generates an empty subpart.

This seems to be caused by t3lib_parsehtml::getSubpart which will return “” even if a valid (but empty) subpart is found.

if (preg_match(‘/^([^\<]*\-\-\>)(.)(\<\!\-\-[^\>])$/s’, $content, $matches)===1) {
return $matches2;
}

which causes an issue in class tslib_cObj ( around line 2529 and other places similar code is used)

if (is_array($conf[‘subparts.’])) {
reset($conf[‘subparts.’]);
while(list($theKey,$theValue)=each($conf[‘subparts.’])) {
if (!strstr($theKey,’.’)) {
$subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
if ($subpart) {
$GLOBALS[‘TSFE’]->register[‘SUBPART_’.$theKey] = $subpart;
$subparts[$theKey][‘name’] = $theValue;
$subparts[$theKey][‘conf’] = $conf[‘subparts.’][$theKey.’.’];
}
}
}
}
where the returned subpart is “” (false) and hence the subpart isn’t included in the subparts array.

Possible fixes;
Add dummy text to empty subparts
if (preg_match(‘/^([^\<]*\-\-\>)(.)(\<\!\-\-[^\>])$/s’, $content, $matches)===1) {
if(strlen($matches2)==0) $matches2=‘Dummy Content’;
return $matches2;
}
Have getSubpart return boolean false
$subpart !== false…

(issue imported from #M10359)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.