Attempted all the cache things and still no luck. There's no extra caching systems, at least none that I can find. Based on your comment about switchContext, I've been digging around in the LangRouter plugin to try and find if there's a point that the site_start ever actually equals the correct value. This is the relevant code for when the request comes in:
if ($this->modx->context->get('key') != "mgr" && MODX_API_MODE == false) {
$this->langrouter->logRequest('Unhandled request');
// Get contexts and their cultureKeys
$contextmap = $this->modx->cacheManager->get($this->langrouter->getOption('cacheKey'), $this->langrouter->getOption('cacheOptions'));
if (empty($contextmap)) {
$babelContexts = explode(',', $this->modx->getOption('langrouter.contextKeys', null, $this->modx->getOption('babel.contextKeys'), true));
$contextmap = $this->langrouter->contextmap($babelContexts);
$this->modx->cacheManager->set($this->langrouter->getOption('cacheKey'), $contextmap, 0, $this->langrouter->getOption('cacheOptions'));
}
$this->langrouter->logDump($contextmap, 'contextmap');
// Determine language from request
$queryKey = $this->modx->getOption('request_param_alias', null, 'q');
$query = (isset($_REQUEST[$queryKey])) ? $_REQUEST[$queryKey] : '';
$cultureKey = (strpos($query, '/') !== false) ? substr($query, 0, strpos($query, '/')) : $query;
if ($cultureKey || $query === '') {
// Serve the proper context and language
if (array_key_exists(strtolower($cultureKey), array_change_key_case($contextmap))) {
$contextKey = $this->modx->context->get('key');
if ($contextKey != $contextmap[$cultureKey]) {
$this->modx->switchContext($contextmap[$cultureKey]);
$this->modx->reloadContext($contextmap[$cultureKey]);
}
// Remove cultureKey from request
$_REQUEST[$queryKey] = preg_replace('~^' . preg_quote($cultureKey, '~') . '/(.*)~', '$1', $_REQUEST[$queryKey]);
$_SERVER['REQUEST_URI'] = preg_replace('~^/' . preg_quote($cultureKey, '~') . '/(.*)~', '/$1', $_SERVER['REQUEST_URI']);
$this->langrouter->logRequest('Culture key found in URI');
$this->modx->cultureKey = $cultureKey;
}
The log function on line 2 outputs this, which shows the context as web and the site_start as 1, which I'd expect (note I've added the "from context" string to the log function, just so I can verify where the setting is coming from).
[2019-02-13 15:41:25] (ERROR in LangRouter @ /paas/c0068/www/core/components/langrouter/model/langrouter/langrouter.class.php : 155) Unhandled request:
REQUEST_URI: /nl/index
REDIRECT_URI:
QUERY_STRING: q=nl/index
q: nl/index
Context: web
Site start: 1 - from context
Then, the context gets switched on line 24 based on the URL - I've added the reloadContext call too as you suggested, doesn't seem to be making a difference alas, as when the log is called again on line 32 it outputs:
[2019-02-13 15:41:25] (ERROR in LangRouter @ /paas/c0068/www/core/components/langrouter/model/langrouter/langrouter.class.php : 155) Culture key found in URI:
REQUEST_URI: /index
REDIRECT_URI:
QUERY_STRING: q=nl/index
q: index
Context: nl
Site start: 1 - from context
The context has been changed correctly, but the site_start is still 1, and it's definitely coming from the context.
I've also tried changing the log to check other context settings and those are coming out correct, it's just something weird happening with this site_start for some reason. I think I'm gonna take this to the LangRouter people and see if they can help cause I am still stumped - thanks for the assistance so far though! Figured I'd throw all this up in case it helps someone else down the line.