【问题标题】:Setup realurl to prevent "Bad 'L' parameter" error设置 realurl 以防止“Bad 'L' parameter”错误
【发布时间】:2019-08-25 21:28:44
【问题描述】:

这是当 URL 中存在错误的 L 参数时引发的异常。它污染了/typo3temp/logs/ 文件夹中的typo3_log。
这个异常似乎是随着realurl的2.3.0版本引入的。如果我降级到版本2.2.1,将不再记录错误。对于版本 2.3.1,我还得到了一个 huge 堆栈转储,其中包含整个 TypoScript 配置数组。

触发此错误的 URL 示例如下:

  • 非整数值:
    • https://www.example.org/index.php?uid=1&L=a
  • 与 TypoScript 设置不匹配的整数:
    • config.linkVars = L(0-1)
    • https://www.example.org/index.php?uid=1&L=5
  • 与 TypoScript 设置匹配但与 realurl_config.php 文件中的设置不对应的整数
    • config.linkVars = L(0-6)
    • 'preVars' => array ( 0 => array ( 'GETvar' => 'L', 'valueMap' => array ( 'en' => '1', 'fr' => '2', 'es' => '3', 'it' => '4', ), 'noMatch' => 'bypass', ), )
    • https://www.example.org/index.php?uid=1&L=6
  • sys_language 数据库表中定义的现有语言不匹配的整数

错误信息是这样的

component="DmitryDulepov.Realurl.Encoder.UrlEncoder":realurl 检测到错误的“L”参数(“X”)。页面缓存被禁用以防止传播错误的“L”值 - “

其中X 是错误的参数

realurl 的2.3.2 版本不存在长转储,但2.3.1 版本不存在

我有一个完全正常的设置,可以很好地与这样的 realurl 版本 2.2.x 配合使用

打字稿

config.linkVars = L(0-1)
page.config.linkVars < config.linkVars
config.uniqueLinkVars = 1
config.language = de
config.locale_all = de_DE
config.htmlTag_langKey = de
config.sys_language_uid = 0

[globalVar = GP:L = 1]
config.language = en
config.locale_all = en_SUS
config.htmlTag_langKey = en
config.sys_language_uid = 1
[global]

realurl_conf.php

'preVars' => array (
    0 => array (
        'GETvar' => 'L',
        'valueMap' => array (
            'en' => '1',
        ),
        'noMatch' => 'bypass',
    ),
),

激活的语言英语:id=1,默认语言德语

我搜索了错误消息,但我发现的只是 Dimitri(realurl 的作者)的一些论坛回复,他们声称配置错误,但没有提示错误是什么。

注意

错误没有被触发,因为我网站上的一些链接有错误的 L 参数。访问日志显示那些参数错误的链接来自bots或没有referrer或来自外部链接

【问题讨论】:

    标签: typo3 typo3-7.6.x realurl


    【解决方案1】:

    我之前做了这个补丁,似乎解决了这个问题:

    index 1ce3874..c7004ea 100644
    --- a/Classes/Encoder/UrlEncoder.php
    +++ b/Classes/Encoder/UrlEncoder.php
    @@ -1605,10 +1605,10 @@ class UrlEncoder extends EncodeDecoderBase {
                    addslashes($sysLanguageUid)
                );
                $this->tsfe->set_no_cache($message);
    -           $this->logger->error($message);
    -           if (version_compare(TYPO3_version, '7.6.0', '>=')) {
    -               $this->logger->debug($message, debug_backtrace());
    -           }
    +           //$this->logger->error($message);
    +           //if (version_compare(TYPO3_version, '7.6.0', '>=')) {
    +           //  $this->logger->debug($message, debug_backtrace());
    +           //}
    
                throw new InvalidLanguageParameterException($sysLanguageUid);
            }
    

    我认为 realurl 配置中没有任何东西可以修复它。所以你必须应用这个补丁。我个人使用cweagans/composer-patches,如果您使用composer来管理您网站的依赖关系,这很好。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多