Index: branches/5.2.x/core/units/languages/languages_event_handler.php =================================================================== diff -u -N -r16016 -r16081 --- branches/5.2.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 16016) +++ branches/5.2.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 16081) @@ -1,6 +1,6 @@ Special == 'current' ) { + $event->setEventParam('live_table', true); + } + + parent::dbBuild($object, $event); + } + + /** * Allows to get primary language object * * @param kEvent $event @@ -70,7 +87,17 @@ if ( $event->Special == 'primary' ) { return $this->Application->GetDefaultLanguageId(); } + elseif ( $event->Special == 'current' ) { + $language_id = $this->Application->GetVar('m_lang'); + if ( !$language_id ) { + $language_id = 'default'; + } + + $this->Application->SetVar('m_lang', $language_id); + $this->Application->SetVar($event->getPrefixSpecial() . '_id', $language_id); + } + return parent::getPassedID($event); } Index: branches/5.2.x/core/units/themes/themes_eh.php =================================================================== diff -u -N -r15145 -r16081 --- branches/5.2.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 15145) +++ branches/5.2.x/core/units/themes/themes_eh.php (.../themes_eh.php) (revision 16081) @@ -1,6 +1,6 @@ Special == 'current' ) { + $event->setEventParam('live_table', true); + } + + parent::dbBuild($object, $event); + } + + /** + * Ensures that current theme detection will fallback to primary without extra DB query. + * + * @param kEvent $event Event. + * + * @return integer + */ + public function getPassedID(kEvent $event) + { + if ( $event->Special == 'current' ) { + $theme_id = $this->Application->GetVar('m_theme'); + + if ( !$theme_id ) { + $theme_id = 'default'; + } + + $this->Application->SetVar('m_theme', $theme_id); + $this->Application->SetVar($event->getPrefixSpecial() . '_id', $theme_id); + } + + return parent::getPassedID($event); + } + + /** * Allows to set selected theme as primary * * @param kEvent $event Index: branches/5.2.x/core/kernel/application.php =================================================================== diff -u -N -r16049 -r16081 --- branches/5.2.x/core/kernel/application.php (.../application.php) (revision 16049) +++ branches/5.2.x/core/kernel/application.php (.../application.php) (revision 16081) @@ -1,6 +1,6 @@ GetVar('m_lang'); - - if ( !$language_id ) { - $language_id = 'default'; - } - - $this->SetVar('lang.current_id', $language_id); - $this->SetVar('m_lang', $language_id); - - $lang_mode = $this->GetVar('lang_mode'); - $this->SetVar('lang_mode', ''); - + /** @var LanguagesItem $lang */ $lang = $this->recallObject('lang.current'); - /* @var $lang kDBItem */ if ( !$lang->isLoaded() || (!$this->isAdmin && !$lang->GetDBField('Enabled')) ) { if ( !defined('IS_INSTALL') ) { $this->ApplicationDie('Unknown or disabled language'); } } - - $this->SetVar('lang_mode', $lang_mode); } /** @@ -530,16 +516,8 @@ return $path; } - $theme_id = $this->GetVar('m_theme'); - if ( !$theme_id ) { - $theme_id = 'default'; // $this->GetDefaultThemeId(1); // 1 to force front-end mode! - } - - $this->SetVar('m_theme', $theme_id); - $this->SetVar('theme.current_id', $theme_id); // KOSTJA: this is to fool theme' getPassedID - + /** @var ThemeItem $theme */ $theme = $this->recallObject('theme.current'); - /* @var $theme ThemeItem */ if ( !$theme->isLoaded() || !$theme->GetDBField('Enabled') ) { return false;