So, after updating from symfony4 to symfony6, i'm trying to deploy on a preprod server, but it is not working well, since our Kernel.php don't seems to have GCP vars anymore in the $_SERVER globals.
This is our Kernel config, where we override the getCacheDir method, to determine the cache path, which was working with symfony4.
public function getCacheDir(): string
{
if ($this->onAppEngine())
return "/tmp/" . $this->environment . '/cache';
return $this->getProjectDir() . '/var/cache/' . $this->environment;
}
private function onAppEngine(): bool
{
return isset($_SERVER['GAE_INSTANCE']);
}
First thing to mention, is that if i remove my condition, (ie return the /tmp path directly in getCacheDir), everything work well (but that's not working in dev env, since it is not the right path for the cache in dev) so i'm pretty sure (but i may be wrong) that the $server var i want is not populated anymore.
So the behaviour is really strange,i have to mention that our website is multi-lingual. I tried to put a dump($server["gae_instance"]), when i reached the base url (example.com) just before redirecting to the localised url, and here, i can see that we do have our $_server var (i saw the value of the dumped $_SERVER['GAE_INSTANCE'] just before redirecting)
So knowing that, it seems that we do have our $_SERVER GAE_INSTANCE on the first request (example.com) but once redirected (to example.com/fr) it's not present anymore (wrong cache path is given and i get errors)
I do think it is a change between symfony4 and symfony6, because we didn't change anything on gcp (except the php version of the app, but we passed from php7.4 to php8.1 and in google docs, it don't seems to impact something https://cloud.google.com/appengine/docs/standard/php-gen2/runtime?hl=fr#php-8.1)
I have to mention that we used to have a translation bundle (jmsi18n) that i removed, since we now use the symfony translation bundle, (I don't really think it's the source of the problem, but i don't want to miss something.)
####EDIT####
Here some test code and resulting logs (i've tried with both print_r and syslog cause i wasn't sure which one were logging)
first i tried with no condition to return the cache dir, and many logs to follow step by step, everything seems ok, all expected logs are sends (and the website is working)
Then I tried the same code, (with some additionals logs) but with the return in the condition, and the bug appends even if we enter the condition, it is becoming really strange, it may be linked, but the kernel is triggered multiple times for one request (and gcp logs show two 500 request on /fr, but we do pass in all expected conditions each time)