Skip to content

修复多语言绑定域名匹配失败导致绑定语言退回默认语言 - #82

Open
defgaaa wants to merge 1 commit into
pbootcmspro:masterfrom
defgaaa:fix/area-domain-bind-match
Open

defgaaa wants to merge 1 commit into
pbootcmspro:masterfrom
defgaaa:fix/area-domain-bind-match

Conversation

@defgaaa

@defgaaa defgaaa commented Oct 28, 2026

Copy link
Copy Markdown

HomeController 的语言绑定域名检测用 $value['domain'] == get_http_host() 直接字符串相等比较,两侧都可能不是规范形式:

  • 配置侧:早期版本保存区域时还没有 filter_area_domain() 过滤,库中 可能存着 http://en.example.com、en.example.com/ 或带大写的主机名
  • 请求侧:get_http_host() 只按 SERVER_PORT 去端口,不做小写化, 反代传入大写 Host 或带尾部点时原样返回

任一侧不规范就漏匹配,访问绑定了二级域名的语言时 cookie('lg') 不被设置,
随后退回 get_default_lg(),页面显示默认语言内容。

新增 match_area_bind_acode(),两侧规范化后再比较:配置侧复用
filter_area_domain(),请求侧复用 parse_http_host()。同时跳过未填域名的 区域,避免 PHP 8 下未定义键告警,并在 lgs 非数组时不再触发 count() 致命错误。

HomeController 的语言绑定域名检测用 $value['domain'] == get_http_host()
直接字符串相等比较,两侧都可能不是规范形式:

- 配置侧:早期版本保存区域时还没有 filter_area_domain() 过滤,库中
  可能存着 http://en.example.com、en.example.com/ 或带大写的主机名
- 请求侧:get_http_host() 只按 SERVER_PORT 去端口,不做小写化,
  反代传入大写 Host 或带尾部点时原样返回

任一侧不规范就漏匹配,访问绑定了二级域名的语言时 cookie('lg') 不被设置,
随后退回 get_default_lg(),页面显示默认语言内容。

新增 match_area_bind_acode(),两侧规范化后再比较:配置侧复用
filter_area_domain(),请求侧复用 parse_http_host()。同时跳过未填域名的
区域,避免 PHP 8 下未定义键告警,并在 lgs 非数组时不再触发 count() 致命错误。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant