Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F727122
D419.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
Mon, Jan 6, 7:04 AM
Size
1 KB
Mime Type
text/x-diff
Expires
Tue, Jan 7, 7:04 AM (3 d, 3 m ago)
Engine
blob
Format
Raw Data
Handle
537184
Attached To
D419: INP-1816 - Use argument-based cache in the "kApplication::GetDefaultThemeId" method
D419.diff
View Options
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
Log In to Comment