Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F804055
D367.id908.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:05 AM
Size
2 KB
Mime Type
text/x-diff
Expires
Thu, Feb 27, 9:05 AM (4 h, 38 m)
Engine
blob
Format
Raw Data
Handle
576769
Attached To
D367: INP-1770 Load default user persistent settings all at once
D367.id908.diff
View Options
Index: core/kernel/session/session_storage.php
===================================================================
--- core/kernel/session/session_storage.php
+++ core/kernel/session/session_storage.php
@@ -37,6 +37,13 @@
var $PersistentVars = Array ();
+ /**
+ * Default persistent vars
+ *
+ * @var array
+ */
+ protected $defaultPersistentVars = array();
+
var $OriginalData = Array ();
var $TimestampField;
@@ -337,16 +344,40 @@
function LoadPersistentVars()
{
$user_id = $this->Session->RecallVar('user_id');
- if ($user_id != USER_GUEST) {
- // root & normal users
- $sql = 'SELECT VariableValue, VariableName
- FROM '.TABLE_PREFIX.'UserPersistentSessionData
- WHERE PortalUserId = '.$user_id;
- $this->PersistentVars = (array)$this->Conn->GetCol($sql, 'VariableName');
+
+ if ( $user_id != USER_GUEST ) {
+ // Root & normal users.
+ $this->PersistentVars = $this->getPersistentVars($user_id);
}
else {
$this->PersistentVars = Array ();
}
+
+ $default_user_id = (int)$this->Application->ConfigValue('DefaultSettingsUserId');
+
+ if ( !$default_user_id ) {
+ $default_user_id = USER_ROOT;
+ }
+
+ if ( $user_id != $default_user_id ) {
+ $this->defaultPersistentVars = $this->getPersistentVars($default_user_id);
+ }
+ }
+
+ /**
+ * Get persistent vars
+ *
+ * @param integer $user_id User Id.
+ *
+ * @return array
+ */
+ protected function getPersistentVars($user_id)
+ {
+ $sql = 'SELECT VariableValue, VariableName
+ FROM ' . TABLE_PREFIX . 'UserPersistentSessionData
+ WHERE PortalUserId = ' . $user_id;
+
+ return (array)$this->Conn->GetCol($sql, 'VariableName');
}
/**
@@ -412,23 +443,16 @@
return $this->PersistentVars[$var_name];
}
elseif ( $default == ALLOW_DEFAULT_SETTINGS ) {
- $default_user_id = $this->Application->ConfigValue('DefaultSettingsUserId');
+ if ( isset($this->defaultPersistentVars[$var_name]) ) {
+ $value = $this->defaultPersistentVars[$var_name];
+ $this->StorePersistentVar($var_name, $value);
- if ( !$default_user_id ) {
- $default_user_id = USER_ROOT;
+ return $value;
}
- $sql = 'SELECT VariableValue, VariableName
- FROM ' . TABLE_PREFIX . 'UserPersistentSessionData
- WHERE VariableName = ' . $this->Conn->qstr($var_name) . ' AND PortalUserId = ' . $default_user_id;
- $value = $this->Conn->GetOne($sql);
- $this->PersistentVars[$var_name] = $value;
+ $this->PersistentVars[$var_name] = false;
- if ( $value !== false ) {
- $this->StorePersistentVar($var_name, $value); //storing it, so next time we don't load default user setting
- }
-
- return $value;
+ return false;
}
return $default;
@@ -525,4 +549,4 @@
throw new BadMethodCallException('Unsupported');
}
-}
\ No newline at end of file
+}
Event Timeline
Log In to Comment