Commit fd2be8b3 authored by Benni Mack's avatar Benni Mack Committed by Georg Ringer
Browse files

[TASK] Deprecate parseFunc.sword functionality

The parseFunc.sword functionality wraps HTML (usually a span tag)
around RTE-based content if:
* GET parameter ?sword[]=search-word is set
* no_cache=1 is set via GET parameter or TypoScript

This feature only works in non-cached environments due to the actual
problem that the search term should never be cached.

This happens if a result page in indexed search is clicked, which
then receives a no_cache=1 argument. This feature is highly discouraged
due to the possible server load that is created, and thus removed.

The existing solution is far from optimal and should rather be handled in
third-party extensions (such as EXT:solr does it via a HighlightViewHelper).

Resolves: #95318
Releases: master
Change-Id: If74247bad14a87c55d092322f0a609c3663f2e67
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71176

Reviewed-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
parent 94da8628
.. include:: ../../Includes.txt
================================================
Deprecation: #95318 - TypoScript parseFunc.sword
================================================
See :issue:`95318`
Description
===========
The TypoScript option `parseFunc.sword` allows to wrap
search words (such as defined via GET parameter `sword_list%5B%5D=MySearchText`)
in a special wrap when `no_cache=1` is set. This functionality has been
deprecated as this feature only works in non_cached environments, which
is not a recommended solution by TYPO3.
Since this behavior is enabled by default, it is highly recommended to avoid
this in general, which can be achieved by disabling the `no_cache=1` GET parameter
in DefaultConfiguration.php.
Also, such an option within `parseFunc` does not cover all cases to highlight
a search word, such as in headlines or HTML content which is not rendered
via `parseFunc`.
Impact
======
Websites called via `https://example.com/?no_cache=1&sword_list%5B%5D=MySearchText` and a custom sword
wrap will trigger a deprecation notice.
As this feature is seldom used and only configured with indexed
search as desired functionality, deprecations are only triggered
when explicitly configured.
In addition, this feature only works if `disableNoCacheParameter`
is disabled or `config.no_cache = 1` is explicitly set via TypoScript
which is also not recommended in production.
Affected Installations
======================
TYPO3 installations actively using the GET argument `sword_list` and have
no_cache` as allowed GET argument enabled, usually in cases where indexed
search is in use.
Migration
=========
It is recommended to implement this functionality on the client-side via
JavaScript as a custom solution, when this feature is needed.
Setting `lib.parseFunc.sword = ` will actively disable the functionality
and not trigger any deprecation warning as well.
Setting `lib.parseFunc.sword = <span class="ce-sword">|</span>`
will also trigger no deprecation warning for TYPO3 v11.
.. index:: Frontend, TypoScript, NotScanned, ext:frontend
......@@ -32,6 +32,7 @@ lib.parseFunc {
}
allowTags = {$styles.content.allowTags}
denyTags = *
# deprecated - will be removed in TYPO3 v12
sword = <span class="ce-sword">|</span>
constants = 1
nonTypoTagStdWrap {
......
......@@ -3574,10 +3574,16 @@ class ContentObjectRenderer implements LoggerAwareInterface
$data = $this->mailto_makelinks($data, $conf['makelinks.']['mailto.'] ?? []);
}
// Search Words:
if (($tsfe->no_cache ?? false) && $conf['sword'] && is_array($tsfe->sWordList) && $tsfe->sWordRegEx) {
// @deprecated since TYPO3 v11, will be removed in TYPO3 v12.0.
if (($tsfe->no_cache ?? false) && ($conf['sword'] ?? false) && is_array($tsfe->sWordList) && $tsfe->sWordRegEx) {
if ($conf['sword'] !== '<span class="ce-sword">|</span>') {
trigger_error('Enabling lib.parseFunc.sword will stop working in TYPO3 v12.0. Consider creating your own parser logic in a custom extension (which ideally also works with active caching.', E_USER_DEPRECATED);
}
$newstring = '';
do {
$pregSplitMode = 'i';
// @deprecated
// @todo: ensure these options are removed from the TypoScript reference in TYPO3 v12.0.
if (isset($tsfe->config['config']['sword_noMixedCase']) && !empty($tsfe->config['config']['sword_noMixedCase'])) {
$pregSplitMode = '';
}
......@@ -3595,7 +3601,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
// The searchword:
$match = substr($data, strlen($pieces[0]), $match_len);
if (trim($match) && strlen($match) > 1 && !$inTag) {
$match = $this->wrap($match, $conf['sword']);
$match = $this->wrap($match, $conf['sword'] ?? '');
}
// Concatenate the Search Word again.
$newstring .= $match;
......
......@@ -506,6 +506,7 @@ class SearchController extends ActionController
// Prepare search words for markup in content:
$markUpSwParams = [];
if ($this->settings['forwardSearchWordsInResultLink']['_typoScriptNodeValue']) {
// @deprecated: this feature will have no effect anymore in TYPO3 v12, and will be disabled
if ($this->settings['forwardSearchWordsInResultLink']['no_cache']) {
$markUpSwParams = ['no_cache' => 1];
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment