ext-solr icon indicating copy to clipboard operation
ext-solr copied to clipboard

CE and REcords in default language after plugin.tx_solr_PiSearch_Search in version 11

Open jurajsulek opened this issue 5 years ago • 1 comments

We have on some pages in header <f:cObject typoscriptObjectPath="plugin.tx_solr_PiSearch_Search"></f:cObject>

in the solr version < 11 everything works fine. But in the version 11.* after the <f:cObject typoscriptObjectPath="plugin.tx_solr_PiSearch_Search"></f:cObject>

on translated pages, every record or CE is shown in default language. It is stange because on first rendering sometimes everything is ok, but then if the caches are flushed the content on the page changes to default language. Then if we open and save some CE on the page the content is back in the translated language until the caches are flushed.

The only solution is to move the <f:cObject typoscriptObjectPath="plugin.tx_solr_PiSearch_Search"></f:cObject> to the end of the page and position it absolutly or move it then with js in the right div.

Tested on Typo3 9 and 10

jurajsulek avatar Jun 24 '20 07:06 jurajsulek

I had the same problem, and debugged it. The main problem in Solr 11.2.0 is that the plugin is calling the Site resolver and TypoScript resolving without handing in the language. I fixed it with this patch.

diff -ru Classes/FrontendEnvironment/TypoScript.php Classes/FrontendEnvironment/TypoScript.php
--- Classes/FrontendEnvironment/TypoScript.php	2022-02-03 11:36:51.000000000 +0100
+++ Classes/FrontendEnvironment/TypoScript.php	2022-08-18 00:27:30.000000000 +0200
@@ -29,9 +29,16 @@
      * @param int $language System language uid, optional, defaults to 0
      * @return TypoScriptConfiguration The Solr configuration for the requested tree.
      */
-    public function getConfigurationFromPageId($pageId, $path, $language = 0)
+    public function getConfigurationFromPageId($pageId, $path, $language = null)
     {
         $pageId = $this->getConfigurationPageIdToUse($pageId);
+        if ($language === null) {
+            if ($GLOBALS['TSFE'] && $GLOBALS['TSFE']->getLanguage()) {
+                $language = $GLOBALS['TSFE']->getLanguage()->getLanguageId();
+            } else {
+                $language = 0;
+            }
+        }

         $cacheId = md5($pageId . '|' . $path . '|' . $language);
         if (isset($this->configurationObjectCache[$cacheId])) {
diff -ru Classes/FrontendEnvironment.php Classes/FrontendEnvironment.php
--- Classes/FrontendEnvironment.php	2022-02-03 11:36:51.000000000 +0100
+++ Classes/FrontendEnvironment.php	2022-08-18 00:27:08.000000000 +0200
@@ -92,7 +92,7 @@
      * @param ?int $language
      * @return TypoScriptConfiguration
      */
-    public function getConfigurationFromPageId($pageId, $path = '', $language = 0): TypoScriptConfiguration
+    public function getConfigurationFromPageId($pageId, $path = '', $language = null): TypoScriptConfiguration
     {
         return $this->typoScript->getConfigurationFromPageId($pageId, $path, $language);
     }
@@ -119,8 +119,8 @@
      * @param ?int $language
      * @return TypoScriptConfiguration
      */
-    public function getSolrConfigurationFromPageId($pageId, $language = 0): TypoScriptConfiguration
+    public function getSolrConfigurationFromPageId($pageId, $language = null): TypoScriptConfiguration
     {
         return $this->getConfigurationFromPageId($pageId, '', $language);
     }
-}
\ No newline at end of file
+}

bmack avatar Aug 17 '22 22:08 bmack