Skip to content

Commit

Permalink
Use contentPostProc-all instead of contentPostProc-output (#1)
Browse files Browse the repository at this point in the history
* Use contentPostProc-all instead of contentPostProc-output

If content comes from cache the usage of stdWrap fails because cObj is not set.
To fix the issue i register the contentPostProc-all hook to make replacements before writing to cache.

* set version to 1.2.0
  • Loading branch information
ger4003 authored and pascal20997 committed Sep 27, 2018
1 parent 3c25565 commit e533b36
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions Classes/Hooks/TypoScriptFrontendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;

/**
* Class TypoScriptFrontendController
Expand Down Expand Up @@ -44,7 +45,7 @@ class TypoScriptFrontendController
* @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $ref
* @return void
*/
public function contentPostProcOutput(
public function contentPostProcAll(
array &$params,
\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $ref
) {
Expand All @@ -64,9 +65,11 @@ public function contentPostProcOutput(
continue;
}
if (!empty($ref->config['config']['tx_replacer.'][$name . '.'][$key . '.'])) {
${$name}[] = $ref->cObj->stdWrap(
$content,
$ref->config['config']['tx_replacer.'][$name . '.'][$key . '.']);
if ($ref->cObj instanceof ContentObjectRenderer) {
${$name}[] = $ref->cObj->stdWrap(
$content,
$ref->config['config']['tx_replacer.'][$name . '.'][$key . '.']);
}
} else {
${$name}[] = $content;
}
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 0,
'version' => '1.1.0',
'version' => '1.2.0',
'constraints' => [
'depends' => [
'typo3' => '7.6.0-8.7.99',
Expand Down
4 changes: 2 additions & 2 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
defined('TYPO3_MODE') or die();

// Register hook
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'][] =
\JWeiland\Replacer\Hooks\TypoScriptFrontendController::class . '->contentPostProcOutput';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'][] =
\JWeiland\Replacer\Hooks\TypoScriptFrontendController::class . '->contentPostProcAll';

0 comments on commit e533b36

Please sign in to comment.