Cannot reproduce Session caching and trophy awards...

Jaxel

Well-known member
Affected version
2.0.5
It seems on every page load, I'm getting about 20 extra queries. All the queries are various forms of:
Code:
INSERT IGNORE INTO `xf_user_trophy` (`user_id`, `trophy_id`, `award_date`) VALUES (?, ?, ?)

Code:
XF\Db\Mysqli\Statement->execute() in src/XF/Db/AbstractAdapter.php at line 79
XF\Db\AbstractAdapter->query() in src/XF/Db/AbstractAdapter.php at line 161
XF\Db\AbstractAdapter->insert() in src/XF/Repository/Trophy.php at line 83
XF\Repository\Trophy->awardTrophyToUser() in src/XF/Repository/Trophy.php at line 70
XF\Repository\Trophy->updateTrophiesForUser() in src/XF/Pub/App.php at line 182
XF\Pub\App->updateUserCaches() in src/XF/Pub/App.php at line 122
XF\Pub\App->start() in src/XF/App.php at line 1890
XF\App->run() in src/XF.php at line 328
XF::runApp() in index.php at line 13

The issue appears to be related to session caching... removing the following lines from my config.php solved the issue:
Code:
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
 
Because I'm sure it will get asked, this is while using a Memcached socket for caching.

Code:
$config['cache']['enabled'] = true;

$config['cache']['provider'] = 'Memcached';
$config['cache']['config'] = [
    'server' => '/tmp/memcached.sock',
        //'port' => 11211,
        'port' => 0,
        'persistent' => true,
        'weight' => 1,
        'timeout' => 5,
        'retry_interval' => 15,
        'status' => true,
];
 
The exact code being hit is wrapped with this:
PHP:
if ($this->options()->enableTrophies && !$session->trophyChecked)
{
   $session->trophyChecked = true;
So for it to be happening on every page load, then it seems the session data being added on this line:
PHP:
$session->trophyChecked = true;
Isn't actually being saved.

This isn't something we can reproduce here, but the behaviour does suggest a faulty cache implementation.
 
Back
Top Bottom