Page MenuHomeIn-Portal Phabricator

D419.diff
No OneTemporary

File Metadata

Created
Mon, Jan 6, 7:04 AM

D419.diff

Index: branches/5.2.x/core/kernel/application.php
===================================================================
--- branches/5.2.x/core/kernel/application.php
+++ branches/5.2.x/core/kernel/application.php
@@ -621,36 +621,38 @@
*/
public function GetDefaultThemeId($force_front = false)
{
- static $theme_id = 0;
+ static $cache = array('force_front=yes' => 0, 'force_front=no' => 0);
- if ( $theme_id > 0 ) {
- return $theme_id;
+ $static_cache_key = $force_front ? 'force_front=yes' : 'force_front=no';
+
+ if ( $cache[$static_cache_key] > 0 ) {
+ return $cache[$static_cache_key];
}
if ( kUtil::constOn('DBG_FORCE_THEME') ) {
- $theme_id = DBG_FORCE_THEME;
+ $cache[$static_cache_key] = DBG_FORCE_THEME;
}
elseif ( !$force_front && $this->isAdmin ) {
- $theme_id = 999;
+ $cache[$static_cache_key] = 999;
}
else {
$cache_key = 'primary_theme[%ThemeSerial%]';
- $theme_id = $this->getCache($cache_key);
+ $cache[$static_cache_key] = $this->getCache($cache_key);
- if ( $theme_id === false ) {
+ if ( $cache[$static_cache_key] === false ) {
$this->Conn->nextQueryCachable = true;
$sql = 'SELECT ' . $this->getUnitOption('theme', 'IDField') . '
FROM ' . $this->getUnitOption('theme', 'TableName') . '
WHERE (PrimaryTheme = 1) AND (Enabled = 1)';
- $theme_id = $this->Conn->GetOne($sql);
+ $cache[$static_cache_key] = $this->Conn->GetOne($sql);
- if ( $theme_id !== false ) {
- $this->setCache($cache_key, $theme_id);
+ if ( $cache[$static_cache_key] !== false ) {
+ $this->setCache($cache_key, $cache[$static_cache_key]);
}
}
}
- return $theme_id;
+ return $cache[$static_cache_key];
}
/**

Event Timeline