Infinite loop
-
The “locale” filter which calls the on_locale() function can raise an infinite loop, that makes the browser tab crash.
A solution is to unhook the “locale” filter at the beginning of the on_locale() function, then rehook it before each “return” in the same function.
Here is the amended function (in file wp-native-dashboard.php)://setup the correct user prefered language function on_locale($loc) { // FG: To avoid an infinite loop remove_filter('locale', array(&$this, 'on_locale'), 9999); if($this->orig_locale === false) $this->orig_locale = $loc; $skip = !$this->options->enable_login_selector && !$this->options->enable_profile_extension && !$this->options->enable_language_switcher && !$this->options->enable_adminbar_switcher; if ((is_admin() && !$skip) || ($this->options->translate_front_adminbar && $this->user_agent_is_wp_native_dashboard)) { if (function_exists('wp_get_current_user')) { $u = wp_get_current_user(); if (!is_object($u) || $u->ID == 0) return $loc; //bugfix: for ajax based login's if (!isset($u->wp_native_dashboard_language)) { if ($loc) $u->wp_native_dashboard_language = $loc; else $u->wp_native_dashboard_language = 'en_US'; } if(($u->wp_native_dashboard_language != 'en_US') && !@file_exists(WP_LANG_DIR.'/' . $u->wp_native_dashboard_language.'.mo')) { // FG: Rehook this function add_filter('locale', array(&$this, 'on_locale'), 9999); return $loc ? $loc : 'en_US'; } // FG: Rehook this function add_filter('locale', array(&$this, 'on_locale'), 9999); return $u->wp_native_dashboard_language; } } // FG: Rehook this function add_filter('locale', array(&$this, 'on_locale'), 9999); return $loc; }
- The topic ‘Infinite loop’ is closed to new replies.