Skip to content

Commit e6cd301

Browse files
authored
Merge pull request #251 from topcoder-platform/issues-217
Issues-247
2 parents a5cdbb0 + 2f75cf1 commit e6cd301

File tree

7 files changed

+430
-18
lines changed

7 files changed

+430
-18
lines changed

config/vanilla/bootstrap.before.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ function _formatStringCallback($match, $setArgs = false) {
263263
// Manually build instead of using userAnchor() because of special 'You' case.
264264
if(function_exists('topcoderRatingCssClass') &&
265265
function_exists('topcoderRoleCssStyles')) {
266-
$ratingCssClass = topcoderRatingCssClass($user->Name);
267-
$roleCssClass = topcoderRoleCssStyles($user->Name);
266+
$ratingCssClass = topcoderRatingCssClass($user);
267+
$roleCssClass = topcoderRoleCssStyles($user);
268268
$topcoderStyles =$ratingCssClass.' '.$roleCssClass;
269269
$result = anchor(htmlspecialchars($name), userUrl($user), $topcoderStyles);
270270
} else {

config/vanilla/config.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// Cache
1111
$Configuration['Cache']['Enabled'] = getenv('CACHE_ENABLED');
1212
$Configuration['Cache']['Method'] = getenv('CACHE_METHOD');
13+
$Configuration['Cache']['Memcached']['Store']=[getenv('MEMCACHED_SERVER')];
1314

1415
// Conversations
1516
$Configuration['Conversations']['Version'] = '3.0';
@@ -144,8 +145,6 @@
144145
$Configuration['Vanilla']['EnableCategoryFollowing'] = true;
145146
$Configuration['Vanilla']['Version'] = '3.0';
146147

147-
// memcached
148-
$Configuration['memcached']['Store'] = getenv('MEMCACHED_SERVER');
149148

150149
// Initial setup config
151150

docker-compose.dev.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@ services:
1212
command: --default-authentication-plugin=mysql_native_password
1313
vanilla-forums:
1414
links:
15-
- mysql-local
15+
- mysql-local
16+
- memcached-local
17+
memcached-local:
18+
image: memcached:1.5
19+
container_name: memcached-local
20+
ports:
21+
- "11211:11211"

vanilla/applications/dashboard/models/class.usermodel.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,28 +1301,29 @@ public function get($orderFields = '', $orderDirection = 'asc', $limit = false,
13011301
* @param string $username The username of the user.
13021302
* @return bool|object Returns the user or **false** if they don't exist.
13031303
*/
1304-
public function getByUsername($username) {
1304+
public function getByUsername($username, $useCache = true) {
13051305
if ($username == '') {
13061306
return false;
13071307
}
13081308

1309-
// Check page cache, then memcached
1310-
$user = $this->getUserFromCache($username, 'name');
1311-
1312-
if ($user === Gdn_Cache::CACHEOP_FAILURE) {
1309+
if($useCache === false ){
13131310
$this->userQuery();
13141311
$user = $this->SQL->where('u.Name', $username)->get()->firstRow(DATASET_TYPE_ARRAY);
1315-
if ($user) {
1316-
// If success, cache user
1317-
$this->userCache($user);
1312+
} else {
1313+
// Check page cache, then memcached
1314+
$user = $this->getUserFromCache($username, 'name');
1315+
if ($user === Gdn_Cache::CACHEOP_FAILURE) {
1316+
$this->userQuery();
1317+
$user = $this->SQL->where('u.Name', $username)->get()->firstRow(DATASET_TYPE_ARRAY);
13181318
}
13191319
}
13201320

1321-
// Apply calculated fields
1322-
$this->setCalculatedFields($user);
1323-
13241321
// By default, firstRow() gives stdClass
13251322
if ($user !== false) {
1323+
// If success, cache user
1324+
$this->userCache($user);
1325+
// Apply calculated fields
1326+
$this->setCalculatedFields($user);
13261327
$user = (object)$user;
13271328
}
13281329

vanilla/applications/vanilla/views/discussions/helper_functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function writeDiscussion($discussion, $sender, $session) {
130130

131131
$first = userBuilder($discussion, 'First');
132132
$last = userBuilder($discussion, 'LastDiscussionComments');
133-
$lastDate = $discussion->LastDiscussionComments;
133+
$lastDate = val('LastDiscussionComments', $discussion);
134134
$sender->EventArguments['FirstUser'] = &$first;
135135
$sender->EventArguments['LastUser'] = &$last;
136136

0 commit comments

Comments
 (0)