Skip to content

Commit 187fb64

Browse files
botwebirnnr
authored andcommitted
[BUGFIX] Ignore HTML comments between TYPO3SEARCH markers
The extractor was not working correctly, if there were HTML comments in between the markers. This change should also make extraction process more performant. Change-Id: I3761951a594bad138776549a5bbd6fb8c894c100
1 parent 72d92cb commit 187fb64

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

Classes/Typo3PageContentExtractor.php

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,11 @@ public function getIndexableContent() {
6969
* @return string HTML markup found between TYPO3SEARCH markers
7070
*/
7171
protected function extractContentMarkedForIndexing($html) {
72-
$explodedContent = preg_split('/\<\!\-\-[\s]?TYPO3SEARCH_/', $html);
73-
$indexableContent = '';
74-
75-
if(count($explodedContent) > 1) {
76-
77-
foreach($explodedContent as $explodedContentPart) {
78-
$contentPart = explode('-->', $explodedContentPart, 2);
79-
80-
if (trim($contentPart[0]) == 'begin') {
81-
$indexableContent .= $contentPart[1];
82-
$previousExplodedContentPart = '';
83-
} elseif (trim($contentPart[0]) == 'end') {
84-
$indexableContent .= $previousExplodedContentPart;
85-
} else {
86-
$previousExplodedContentPart = $explodedContentPart;
87-
}
88-
}
89-
} else {
90-
if ($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['logging.']['indexing.']['missingTypo3SearchMarkers']) {
91-
t3lib_div::devLog('No TYPO3SEARCH markers found.', 'solr', 2);
92-
}
72+
preg_match_all('/\<\!\-\-[\s]?TYPO3SEARCH_begin[\s]?\-\-\>(.|\s)*?\<\!\-\-[\s]?TYPO3SEARCH_end[\s]?\-\-\>/mi', $html, $indexableContents);
73+
$indexableContent = implode($indexableContents[0], '');
74+
75+
if(empty($indexableContent) && $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['logging.']['indexing.']['missingTypo3SearchMarkers']) {
76+
t3lib_div::devLog('No TYPO3SEARCH markers found.', 'solr', 2);
9377
}
9478

9579
return $indexableContent;

0 commit comments

Comments
 (0)