}
else {
// load storage data
- UserStorageHandler::getInstance()->loadStorage(array($this->userID), 1);
+ UserStorageHandler::getInstance()->loadStorage(array($this->userID));
// get group ids
- $data = UserStorageHandler::getInstance()->getStorage(array($this->userID), 'groupIDs', 1);
+ $data = UserStorageHandler::getInstance()->getStorage(array($this->userID), 'groupIDs');
// cache does not exist or is outdated
if ($data[$this->userID] === null) {
}
else {
// load storage data
- UserStorageHandler::getInstance()->loadStorage(array($this->userID), 1);
+ UserStorageHandler::getInstance()->loadStorage(array($this->userID));
// get language ids
- $data = UserStorageHandler::getInstance()->getStorage(array($this->userID), 'languageIDs', 1);
+ $data = UserStorageHandler::getInstance()->getStorage(array($this->userID), 'languageIDs');
// cache does not exist or is outdated
if ($data[$this->userID] === null) {
<?php
namespace wcf\system\user\collapsible\content;
use wcf\data\object\type\ObjectTypeCache;
+use wcf\system\user\storage\UserStorageHandler;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
$this->collapsedContent[$objectTypeID] = array();
if (WCF::getUser()->userID) {
- $sql = "SELECT objectID
- FROM wcf".WCF_N."_user_collapsible_content
- WHERE objectTypeID = ?
- AND userID = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array(
- $objectTypeID,
- WCF::getUser()->userID
- ));
- while ($row = $statement->fetchArray()) {
- $this->collapsedContent[$objectTypeID][] = $row['objectID'];
+ // get data from storage
+ UserStorageHandler::getInstance()->loadStorage(array(WCF::getUser()->userID));
+
+ // get ids
+ $data = UserStorageHandler::getInstance()->getStorage(array(WCF::getUser()->userID), 'collapsedContent-'.$objectTypeID);
+
+ // cache does not exist or is outdated
+ if ($data[WCF::getUser()->userID] === null) {
+ $sql = "SELECT objectID
+ FROM wcf".WCF_N."_user_collapsible_content
+ WHERE objectTypeID = ?
+ AND userID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array(
+ $objectTypeID,
+ WCF::getUser()->userID
+ ));
+ while ($row = $statement->fetchArray()) {
+ $this->collapsedContent[$objectTypeID][] = $row['objectID'];
+ }
+
+ // update storage data
+ UserStorageHandler::getInstance()->update(WCF::getUser()->userID, 'collapsedContent-'.$objectTypeID, serialize($this->collapsedContent[$objectTypeID]), 1);
+ }
+ else {
+ $this->collapsedContent[$objectTypeID] = @unserialize($data[WCF::getUser()->userID]);
}
}
else {
WCF::getUser()->userID
));
}
+
+ // reset storage
+ UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'collapsedContent-'.$objectTypeID, 1);
}
else {
$collapsedContent = WCF::getSession()->getVar('collapsedContent');
$objectID,
WCF::getUser()->userID
));
+
+ // reset storage
+ UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'collapsedContent-'.$objectTypeID, 1);
}
else {
$collapsedContent = WCF::getSession()->getVar('collapsedContent');
$objectTypeID,
WCF::getUser()->userID
));
+
+ // reset storage
+ UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'collapsedContent-'.$objectTypeID, 1);
}
else {
$collapsedContent = WCF::getSession()->getVar('collapsedContent');
<?php
namespace wcf\system\user\storage;
use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\package\PackageDependencyHandler;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
public function loadStorage(array $userIDs, $packageID = PACKAGE_ID) {
$tmp = array();
foreach ($userIDs as $userID) {
- if (!isset($this->cache[$userID][$packageID])) $tmp[] = $userID;
+ if (!isset($this->cache[$userID])) $tmp[] = $userID;
}
// ignore users whose storage data is already loaded
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("userID IN (?)", array($tmp));
- $conditions->add("packageID = ?", array($packageID));
+ $conditions->add("packageID IN (?)", array(PackageDependencyHandler::getDependencies($packageID)));
$sql = "SELECT *
FROM wcf".WCF_N."_user_storage
$this->cache[$row['userID']] = array();
}
- if (!isset($this->cache[$row['userID']][$row['packageID']])) {
- $this->cache[$row['userID']][$row['packageID']] = array();
- }
-
- $this->cache[$row['userID']][$row['packageID']][$row['field']] = $row['fieldValue'];
+ $this->cache[$row['userID']][$row['field']] = $row['fieldValue'];
}
}
*
* @param array<integer> $userIDs
* @param string $field
- * @param integer $packageID
* @return array<array>
*/
- public function getStorage(array $userIDs, $field, $packageID = PACKAGE_ID) {
+ public function getStorage(array $userIDs, $field) {
$data = array();
foreach ($userIDs as $userID) {
- if (isset($this->cache[$userID][$packageID][$field])) {
- $data[$userID] = $this->cache[$userID][$packageID][$field];
+ if (isset($this->cache[$userID][$field])) {
+ $data[$userID] = $this->cache[$userID][$field];
}
else {
$data[$userID] = null;
$this->cache[$userID] = array();
}
- if (!isset($this->cache[$userID][$packageID])) {
- $this->cache[$userID][$packageID] = array();
- }
-
- $this->cache[$userID][$packageID][$field] = $fieldValue;
+ $this->cache[$userID][$field] = $fieldValue;
// flag key as outdated
self::reset(array($userID), $field, $packageID);