Hi @oliverhtml,
Sorry to hear that you are having problems. I don’t think we can fix them, but we will have a look.
Best regards from Spain.
Hi there,
it turns out that this is the cause of the intermittent 502 errors we’ve been seeing also. Could you check for one of the redis constants: WP_REDIS_PORT, WP_REDIS_HOST, WP_REDIS_PASSWORD prior to a session_start call or provide a filter that returns whether or not to start a session. I’m conscious that we still want to use the plugin but don’t want to take it off of the update path!
Kind Regards,
Oliver
Hi @oliverhtml,
If you have modified the plugin with the constants, please share the changes and we will test them to include them in the plugin reléase.
Best regards from Spain.
Hi,
this seems to do it for compatability with this plugin: https://ww.wp.xz.cn/plugins/redis-cache/
it’s probably not the best solution overall as it’s specific to that plugin but it does get it running on krystal hosting’s onyx package.
if (!session_id()) {
if(empty(WP_REDIS_HOST) && empty(WP_REDIS_PORT) && empty(WP_REDIS_PASSWORD)){
session_start();
}
}
Thanks,
Oliver
Thanks for the code. Probably we will modify it before our tests to check whether the variable exists with !isset(WP_REDIS_HOST) instead of empty(WP_REDIS_HOST) to avoid errors when the variables are not defined.
!isset(WP_REDIS_HOST) to check whether a variable is not set.
empty(WP_REDIS_HOST) works for:
- “” (an empty string)
- 0 (0 as an integer)
- 0.0 (0 as a float)
- “0” (0 as a string)
- NULL
- FALSE
- array() (an empty array)
- $var; (a variable declared, but without a value)
But we are not sure how it behaves in different PHP versions when the variable is not defined.
Could you please try on your installation if this works for you:
if (!session_id()) {
if(!isset(WP_REDIS_HOST) && !isset(WP_REDIS_PORT) && !isset(WP_REDIS_PASSWORD)){
session_start();
}
}
Best regards from Spain.
-
This reply was modified 7 years, 1 month ago by
apasionados. Reason: added code tag to empty(WP_REDIS_HOST)
Hi again!
I just used empty because it checks whether the variable exists and is the equivalent of : !isset($var) || $var == false
https://www.php.net/manual/en/function.empty.php
I will update to your method and give it a go
Thanks,
Oliver
Ok. Looks like we were wrong and it’s better to use empty: Determine whether a variable is considered to be empty. A variable is considered empty if it does not exist or if its value equals FALSE. empty() does not generate a warning if the variable does not exist.
So we will use empty() then.
Best regards from Spain.