Fixed ErrorException: [E_WARNING] Undefined array key "sessionActivityOptimized"

rdn

Well-known member
Affected version
2.2.8
Error happens during web upgrade from 2.2.7 to 2.2.8, but only once.
Using PHP 8.0.13

PHP:
Server error log
ErrorException: [E_WARNING] Undefined array key "sessionActivityOptimized" src/XF/Repository/SessionActivity.php:125
Generated by: Unknown account Dec 3, 2021 at 4:25 AM

Stack trace
#0 src/XF/Repository/SessionActivity.php(125): XF::handlePhpError(2, '[E_WARNING] Und...', '/home/nginx/dom...', 125)
#1 src/XF/Pub/Controller/AbstractController.php(84): XF\Repository\SessionActivity->updateSessionActivity(0, '54.36.148.108', 'XF\\Pub\\Controll...', 'Index', Array, 'valid', 'ahrefs')
#2 src/XF/Pub/Controller/AbstractController.php(44): XF\Pub\Controller\AbstractController->updateSessionActivity('Index', Object(XF\Mvc\ParameterBag), Object(XF\Mvc\Reply\View))
#3 src/XF/Mvc/Controller.php(289): XF\Pub\Controller\AbstractController->postDispatchType('Index', Object(XF\Mvc\ParameterBag), Object(XF\Mvc\Reply\View))
#4 src/XF/Mvc/Dispatcher.php(385): XF\Mvc\Controller->postDispatch('Index', Object(XF\Mvc\ParameterBag), Object(XF\Mvc\Reply\View))
#5 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF:Thread', 'Index', Object(XF\Mvc\RouteMatch), Object(XFMG\XF\Pub\Controller\Thread), NULL)
#6 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XFMG\XF\Pub\Controller\Thread), NULL)
#7 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#8 src/XF/App.php(2345): XF\Mvc\Dispatcher->run()
#9 src/XF.php(512): XF\App->run()
#10 index.php(20): XF::runApp('XF\\Pub\\App')
#11 {main}

Request state
array(4) {
  ["url"] => string(83) "/threads/title.450070/page-37"
  ["referrer"] => bool(false)
  ["_GET"] => array(1) {
    ["/threads/title_450070/page-37"] => string(0) ""
  }
  ["_POST"] => array(0) {
  }
}
 
During upgrade also I got this error.
Not sure if it's related.

NGINX:
2021/12/03 04:25:23 [error] 37313#0: *7967760 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: my.ip, server: xf.com, request: "POST /install/index.php?upgrade/run-job HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "xf.com", referrer: "https://xf.com/install/index.php?upgrade/run"
 
Directly accessing the URL gives me this error:
PHP:
Server error log
ErrorException: [E_WARNING] Attempt to read property "completed" on null src/XF/Install/Controller/AbstractController.php:26
Generated by: Admin Dec 3, 2021 at 4:36 AM

Stack trace
#0 src/XF/Install/Controller/AbstractController.php(26): XF::handlePhpError(2, '[E_WARNING] Att...', '/home/nginx/dom...', 26)
#1 src/XF/Install/Controller/Upgrade.php(266): XF\Install\Controller\AbstractController->manualJobRunner('index.php?upgra...', 'index.php?upgra...')
#2 src/XF/Mvc/Dispatcher.php(352): XF\Install\Controller\Upgrade->actionRunJob(Object(XF\Mvc\ParameterBag))
#3 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF:Upgrade', 'RunJob', Object(XF\Mvc\RouteMatch), Object(XF\Install\Controller\Upgrade), NULL)
#4 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Install\Controller\Upgrade), NULL)
#5 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#6 src/XF/App.php(2351): XF\Mvc\Dispatcher->run()
#7 src/XF.php(517): XF\App->run()
#8 install/index.php(14): XF::runApp('XF\\Install\\App')
#9 {main}

Request state
array(4) {
  ["url"] => string(34) "/install/index.php?upgrade/run-job"
  ["referrer"] => string(54) "https://xf.com/install/index.php?upgrade/run-job"
  ["_GET"] => array(1) {
    ["upgrade/run-job"] => string(0) ""
  }
  ["_POST"] => array(3) {
    ["_xfRedirect"] => string(55) "https://xf.com/install/index.php?upgrade/complete"
    ["_xfToken"] => string(8) "********"
    ["execute"] => string(1) "1"
  }
}
 
Related: https://xenforo.com/community/threa...t-exceeded-try-restarting-transaction.200189/

Edit: The fix for that bug introduced sessionActivityOptimized. It's possible src/XF/Repository/SessionActivity.php was updated prior to src/XF/App.php, which would result in that error message. This can also happen with some opcache configurations. If that's the cause of the first bug, you can safely ignore it as long as it doesn't happen again.

The other errors are unrelated.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.9).

Change log:
Workaround an undefined array key error that may happen during upgrade
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom