Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache and restore system LC_CTYPE option after all other locales are set #21127

Draft
wants to merge 1 commit into
base: 5.x-dev
Choose a base branch
from

Conversation

michalkleiner
Copy link
Contributor

Description:

Tweak for #21126 that should be functionally equivalent.
Even repeated calls to changing the locale should persist the value for LC_CTYPE from the very first call.

Review

@michalkleiner michalkleiner added the Needs Review PRs that need a code review label Aug 7, 2023
@caddoo
Copy link
Contributor

caddoo commented Aug 9, 2023

According to the PHP docs, https://www.php.net/manual/en/function.setlocale.php

When the argument category is passed as an empty string, it takes the value from the environment variables (in this order):

  1. $LC_CTYPE
  2. $LANG

Are these both blank/empty string for your local environment. The reason for asking the question is to really nail down exactly why it was breaking in the first place.

echo $LC_CTYPE & echo $LANG

@michalkleiner
Copy link
Contributor Author

michalkleiner commented Aug 9, 2023

$LANG has a value, $LC_CTYPE is empty, locale returns both.
locales

@michalkleiner
Copy link
Contributor Author

I think it's not just what I can access as a user in my shell, it's about what nginx or php-fpm is running with, and when testing from plain php script with

<?php

setlocale(LC_CTYPE, '');

it immediately failed the same way.

@michalkleiner
Copy link
Contributor Author

I also tried setting LC_CTYPE and LC_ALL to en_NZ.UTF-8 via fastcgi_param LANG "en_NZ.UTF-8"; in /opt/homebrew/etc/nginx/fastcgi_params and other places without luck, but it's possible that I haven't tried everything-everything.

@github-actions
Copy link
Contributor

This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Aug 24, 2023
@michalkleiner michalkleiner marked this pull request as draft August 24, 2023 07:16
@michalkleiner michalkleiner removed Needs Review PRs that need a code review Stale The label used by the Close Stale Issues action labels Aug 24, 2023
@samjf
Copy link
Contributor

samjf commented Sep 5, 2023

@shafeek-innocraft Had this problem setting up a new matomo install too.

@caddoo
Copy link
Contributor

caddoo commented Sep 8, 2023

@shafeek-innocraft Had this problem setting up a new matomo install too.

I did as well switching from using the built in PHP server to using Nginx + PHP-FPM ➕

@github-actions
Copy link
Contributor

If you don't want this PR to be closed automatically in 28 days then you need to assign the label 'Do not close'.

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Sep 23, 2023
@michalkleiner michalkleiner added Do not close PRs with this label won't be marked as stale by the Close Stale Issues action and removed Stale The label used by the Close Stale Issues action labels Sep 25, 2023
@rikwillems
Copy link

I can confirm this PR resolves the issue for me.

@michalkleiner
Copy link
Contributor Author

Hi @rikwillems, could you please let us know a bit about your current dev environment setup?
Are you using Docker, Ddev, Laravel Valet, MAMP/WAMP or something else?
When did you start seeing the issue, has it started randomly or after an upgrade or similar?
Any other info you can share to help us understand what might be the original cause?

@rikwillems
Copy link

Hi @michalkleiner I just started experimenting with Matomo a little bit. Last week I was able to install without any issue. Today I tried again and ran into this issue. I'm using Valet on php 8.1. Also tried php 8.0, same issue.

For debug I tried a try/catch but that didn't do anything, same 502 error.

@samjf
Copy link
Contributor

samjf commented Sep 28, 2023

@michalkleiner I forgot to mention at the time that when we encountered this the PR did actually solve the issue.
It was also experienced in a Dev environment using Nginx / Valet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Do not close PRs with this label won't be marked as stale by the Close Stale Issues action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants