realURL: Cleanup path-cache and url-cache - typo3

I have some problems with realURL Cache. For example:
The URL to the "home"-page is /the-shoe/home. Translated to switzerland (german) the url is: /ch/der-schuh/home. The problem here is that the URL /ch/the-shoe/home also works.
My idea was, that this is a cache problem. Because the page got translated and the page got called before the title of the page got translated
So I tried to clean the cache with the backend-module "Speaking URLs". I Flush all entries in the URL Cache and deleted the paths für this page and language in the Path Cache.
But this did not change anything. I can still call /ch/der-schuh/home and /ch/the-shoe/home and both works. After calling both URLs I can also see them again in the URL Cache (but not in the Path Cache):
So why is this a problem
I do not want 2 URLs lead to the same content
Sometimes <f:link_page> and co. creates a Link with the "wrong" URL (not the translated one).
When I am logged in in the backend the "wrong" URL will not work!
Now my question is, where is this problem coming from? How can I solve it? It looks like just clearing the cache does not solve the problem.
ANy ideas?

This is a RealURL bug, which I actually had fixed once by patching RealURL (that was in RealURL v1 back then, but I'm sure you will figure out the line of code where it is now).
With this patch applied, it is NOT possible anymore to access a translated page with the original page title in it (which my project needed to avoid duplicate content & pages).
diff --git a/realurl/class.tx_realurl_advanced.php b/realurl/class.tx_realurl_advanced.php
index 5af10a6..2860eb1 100644
--- a/realurl/class.tx_realurl_advanced.php
+++ b/realurl/class.tx_realurl_advanced.php
## -1073,6 +1073,11 ## class tx_realurl_advanced {
// Process titles. Note that excluded segments are also searched
// otherwise they will never be found
$uidTrack[$row['uid']] = $row;
+ // If the page has a page translation, don't add the titles from the default language to the list
+ // of valid pages, the translation is processed below.
+ if ($this->pObj->getDetectedLanguage() > 0) {
+ continue;
+ }
foreach ($segTitleFieldArray as $fieldName) {
if ($row[$fieldName]) {
$encodedTitle = $this->encodeTitle($row[$fieldName]);

The issue is halffixed in realURL v2.0.14.
Best fix for now is to disable cache for realURL.

Related

Magento 2 - Category Image URL showing two paths

Buit of a strange one, but hopefully it's easy to resolve.
I have uploaded some product Category images to certain category pages in the Admin client but when I view them on the web they don't load. The reason appears to be that it is trying to load two paths in the src attribute, which are slightly different.
Any ideas what I need to do to resolve this... :-)
src="https://www.myurl.com/pub/media/catalog/category//pub/media/catalog/tmp/category/25mm.jpg"
As you can see there are two paths in the URL, one has "tmp" (in bold) and if I modify the SRC this one loads. It appears that it is prepending the URL?
Any ideas would be appreciated.
src="/pub/media/catalog/tmp/category/25mm.jpg" <- This one loads the image?
Since Magento 2.3.4 this problem occurs.
/vendor/magento/module-catalog/Model/Category/Attribute/Backend/Image.php
public function beforeSave($object)
In This method below code is creating issue
$value[0]['url'] = '/' . $baseMediaDir . '/' . $newImgRelativePath;
$value[0]['name'] = $value[0]['url'];
Update it with
$value[0]['url'] = $baseMediaDir . $newImgRelativePath;
$value[0]['name'] = $value[0]['name'];
This will fix issue
Do Not forget to override this file from your module to avoid direct core file changes
Github issue: https://github.com/magento/magento2/issues/28100
Which version of magento 2 do you use?
I've had a similar problem with magento 2.3.4
When you save a category for which you just added an image. The model that handles the category images won't move your image from the tmp folder to the pub/media/catalog/category (which should be the path to the image).
So you have to override to Image.php model from the catgeory to move the file from tmp after is saved.
Hope this will help you.

TYPO3 WEC_Map Extension <script> Tag not inserted in HTML

I’m using Typo3 (Version 6.2.14) and upgraded WEC_Map to version 3.1.3 because I saw a warning on my map which says that I need to use an API key for Google Maps.
So I’ve generated an API key for "Maps Static API" and inserted it in WEC Map Admin. (I’ve used the same key for Browser API Key and Server API Key. Only difference is that I’ve added the secret for the Browser API Key separated by a comma.)
If I’ve visit my FE User Map in the backend the map is showing.
In the frontend instead I get the following error: "
There doesn't seem to be anything to display. Make sure the map is configured correctly and there are users or markers set".
Inspecting the source code I saw that the script tag to maps.googleapis.com is not generated. It looks like this is causing the issue, but I don't know why it is happening.
I hope that someone using a similar setup can point me into the right direction.
Thank you guys. (It would be nice if someone could add the Tag for WEC_Map)
Ok I resolved this. The problem was that I was using the userGroups setting to filter the map markers by multiple user groups.
plugin.tx_wecmap_pi2 {
height = 500
width = 500
showDirections = 1
prefillAddress = 0
initialMapType = G_HYBRID_MAP
controls.mapControlSize = large
controls.showOverviewMap = 1
controls.showMapType = 1
controls.showScale = 1
userGroups = 2,3,5
pid = 2,3,5 # <-- This uses a AND condition
}
Since this setting is using an AND condition under the hood I received the error "There doesn't seem to be anything to display. Make sure the map is configured correctly and there are users or markers set"
In fact I opened a feature request for this 3 years ago. Unfortunately the feature request never made it into the plugin. But Jan Bartels posted a workaround as reply to the feature request. This workaround got lost while updating the extension.
Also recomment to the extension authors to make it more clear in their documentation that the property userGroups uses a AND condition.

Xpath starting retuning None on Scrapy

I'm trying to crawl a site and to do so, I'm using Scrapy. So, when doing requests to nested pages, the procedure usually gets the the information correctly on the first trials, but, on later requests the nodes starts to return None. I'm using xpath's functionality. Below I'm pasting some lines of the parse function:
(I tried this one with the approach of explicitly comparing the class value)
title = response.xpath('//span[#class="inlineFree"]/text()').extract_first()
(With this one I used the contains function)
view = response.xpath('//span[contains(#class,"count")]/text()').extract_first()
(I've also used this one when I found more suitable)
comments = response.css('div.commentMessage > span::text').extract()
Am I doing something wrong on paths?
Is there any reason for the crawler to stop reading the nodes correctly?
Cannot say what the problem is without the log messages or the spider code but..
What happens most of the time is that websites fo not follow a strict html structure .For some properties the 'title' may be inside the span
but for the next iteration it may be
span[#class="inlineFree"]/h1/text() or or any other tag
so you should check the html for those returning None

How to disable HTML transformation in TYPO3 8 LTS completely

In TYPO3 8.7.8 LTS and a clean installation with the setting to create one blank basis page during install and the CKEditor extension disabled when you write something in a text element (I think it is the tt_content.bodytext field) it gets transformed (<p> tags added, line breaks removed etc...) even so there is no WYSIWYG-Editor enabled. So this transformation has to happen in the TYPO3 backend.
I'm trying to disable this now for a while but I failed so far. I tried the approaches from https://docs.typo3.org/typo3cms/CoreApiReference/Rte/Transformations/Tsconfig/Index.html
And here mainly
This configuration in "Page TSconfig" will disable the RTE altogether:
RTE.default.disabled = 1
To be precise my Page TSConfig looks like this and the transformation still happens:
RTE.default.proc.dontRemoveUnknownTags_db = 1
RTE.default.proc.entryHTMLparser_db = 0
RTE.default.proc.exitHTMLparser_db = 0
RTE.default.disabled = 1
RTE.config.tt_content.bodytext.proc.dontRemoveUnknownTags_db = 1
RTE.config.tt_content.bodytext.proc.entryHTMLparser_db = 0
RTE.config.tt_content.bodytext.proc.exitHTMLparser_db = 0
RTE.config.tt_content.bodytext.disabled = 1
So the question is, how can I disable the HTML transformations completely? Do I need to add something in the TypoScript Setup (I tried a bit but no luck) or do I have to do something completely different/in a different stop than the Page TSConfig?
Looking at (and debugging) \TYPO3\CMS\Core\Html\RteHtmlParser and here RTE_transform($value, $specConf = [], $direction = 'rte', $thisConfig = []) which seems to be the responsible function for the transformation of this field, I know that the transformations for my case happen in the mode foreach.
I also know that my RTE.default.disabled = 1 wasn't in the wrong place. It was part of the loaded config, however at least at this point it has no effect at all.
What has an effect is setting RTE.default.proc.overruleMode = none or RTE.default.proc.mode = none. One would do it and any string which is not a registered mode works to disable any transformation.
IMHO: The TYPO3 documentation seems as messy as its code base, maybe RTE.default.disabled = 1 has a use case somewhere and maybe you would find it if you would digg further into the documentation but I fear it may also just be an artefact from some old version which most of this pre- and postprocessing logic seems to be (and from what I've seen here in the last two hours I'm not confident other parts of this framework are 'modern', the mere amount of db queries for simplest backend tasks indicates I could be right). Anyways, my problem is solved and good luck to anyone who also needs to work with this reptile from the past for some reason.
tl;dr: set RTE.default.proc.overruleMode = none in your Page TSConfig

TYPO3 - Realurl default Settings overwrite?

How can I overwrite the default settings of the TYPO3 extension realurl with my own extension?
this dont work:
// RealUrl Config File
if (!isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['realurl']['configFile'])
|| empty(trim($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['realurl']['configFile']))
) {
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['realurl']['configFile'] = 'typo3conf/ext/xxx/Resources/Private/Hooks/realurl_conf.php';
}
How can I use this?
Probably the problem is that realurl is inialized and executed very early (it's the first process which needs to translate the speaking url to url parameter which decide which page and which plugin is rendered).
Your attempt to modify the assignment which is done normaly in typo3conf/LocalConfiguration.php could not be attached to that file as it is just an array, which gets written anew automatically every now and then.
You might add that to typo3conf/AdditionalConfiguration.php.
But why don't you request an admin to assign the path to the config-file in your extension in the realurl EM-config by hand?