You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
We start our buffer with template_redirect action and close it with shutdown hook, so if we have a code (custom or in another plugin) that tries to redirect after template_redirect the page url will be saved in preload cache database table.
To Reproduce
Steps to reproduce the behavior:
Use the following snippet:
add_action( 'plugins_loaded', function () {
$current_url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( home_url( $_SERVER['REQUEST_URI'] ) ) : '';
if ( 'http://wprocket.localhost/fonts/' !== $current_url ) { // Replace this url with the page or post url u want.
return;
}
wp_redirect( home_url( '/' ), 301 );
exit;
}, 3 );
Make sure u use this snippet inside a plugin (not inside the theme and not inside snippets plugin) and change the url to match with a real page/post url
Make sure that the url is not in cache database table and it's not cached at all.
Visit the mentioned url
You will be redirected to home page.
The url will be inside cache table and its status is completed.
Expected behavior
This url shouldn't be saved inside preload cache table.
Additional context
Try the following snippet instead, it'll work and fix the issue:
I'm Razvan, developer at TranslatePress. Thank you for sharing a detailed report on this compatibility issue.
Moving the entire translate_request_uri function to the template_redirect hook is not possible because it handles identifying what original URL matches the currently loaded translated URL. This needs to be done earlier than template_redirect.
However, the redirect step can be moved to template_redirect hook. This should solve the issue reported and keep TranslatePress functionality working as expected. The fix should be present in the next update of TranslatePress - Personal (1.3.8+).
Describe the bug
We start our buffer with
template_redirect
action and close it withshutdown
hook, so if we have a code (custom or in another plugin) that tries to redirect aftertemplate_redirect
the page url will be saved in preload cache database table.To Reproduce
Steps to reproduce the behavior:
Expected behavior
This url shouldn't be saved inside preload cache table.
Additional context
Try the following snippet instead, it'll work and fix the issue:
This happened with
Translatepress - Personal
Slack discussion: https://wp-media.slack.com/archives/C056ZJMHG0P/p1733428826901719
Proposed solution for translatepress
The have this line:
exactly here:
if they managed to change it to be
I think this will fix the issue
The text was updated successfully, but these errors were encountered: