TYPO3-Solr / ext-solr

A TYPO3 extension that integrates the Apache Solr search server with TYPO3 CMS. dkd Internet Service GmbH is developing the extension. Community contributions are welcome. See CONTRIBUTING.md for details.
GNU General Public License v3.0
137 stars 250 forks source link

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

Open jurajsulek opened 4 years ago

jurajsulek commented 4 years ago

We have on some pages in header

in the solr version < 11 everything works fine. But in the version 11.* after the 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 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
bmack commented 2 years ago

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
+}