Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F803912
D419.id1038.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 26, 9:01 AM
Size
1 KB
Mime Type
text/x-diff
Expires
Thu, Feb 27, 9:01 AM (5 h, 2 m)
Engine
blob
Format
Raw Data
Handle
576634
Attached To
D419: INP-1816 - Use argument-based cache in the "kApplication::GetDefaultThemeId" method
D419.id1038.diff
View Options
Index: core/kernel/application.php
===================================================================
--- core/kernel/application.php
+++ 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
Log In to Comment