[wp-trac] [WordPress Trac] #57121: 'get_current_user_id' in 'gettext' filter causing memory error
WordPress Trac
noreply at wordpress.org
Fri Nov 18 01:50:24 UTC 2022
#57121: 'get_current_user_id' in 'gettext' filter causing memory error
-------------------------------+---------------------
Reporter: adityaarora010196 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.1.2
Component: Users | Version: 6.1
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-------------------------------+---------------------
Changes (by SergeyBiryukov):
* keywords: => has-patch
Comment:
[attachment:"57121.diff"] appears to work, because it succeeds in setting
the static `$duplicated_keys` array once and no longer goes into this code
section on subsequent calls.
As a workaround until a fix is released, this can also be resolved by
removing the filter before calling `get_current_user_id()` and readding it
after:
{{{
function my_gettext_callback( $translation ) {
remove_filter( 'gettext', __FUNCTION__ );
$user_id = get_current_user_id();
add_filter( 'gettext', __FUNCTION__ );
return $translation;
}
add_filter( 'gettext', 'my_gettext_callback' );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57121#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list