Fixed Error - Rebuild user caches

Affected version
2.1.8

Astra

Member
InvalidArgumentException: Attempted to convert NULL to integer [warning_points] in src/XF/Mvc/Entity/Entity.php at line 740
  1. XF\Mvc\Entity\Entity->_castValueToType() insrc/XF/Mvc/Entity/Entity.php at line 694
  2. XF\Mvc\Entity\Entity->setAsSaved() in src/XF/Mvc/Entity/Entity.php at line 1296
  3. XF\Mvc\Entity\Entity->fastUpdate() in src/XF/Entity/User.php at line 1017
  4. XF\Entity\User->rebuildWarningPoints() in src/XF/Job/User.php at line 51
  5. XF\Job\User->rebuildById() in src/XF/Job/AbstractRebuildJob.php at line 47
  6. XF\Job\AbstractRebuildJob->run() in src/XF/Job/Manager.php at line253
  7. XF\Job\Manager->runJobInternal() in src/XF/Job/Manager.php at line195
  8. XF\Job\Manager->runJobEntry() in src/XF/Job/Manager.php at line 79
  9. XF\Job\Manager->runQueue() in src/XF/Admin/Controller/Tools.php at line 139
  10. XF\Admin\Controller\Tools->actionRunJob() insrc/XF/Mvc/Dispatcher.php at line 350
  11. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 257
  12. XF\Mvc\Dispatcher->dispatchFromMatch() insrc/XF/Mvc/Dispatcher.php at line 113
  13. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 55
  14. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2184
  15. XF\App->run() in src/XF.php at line 391
  16. XF::runApp() in admin.php at line 13
Снимок экрана 2020-03-17 в 21.29.30.png
Снимок экрана 2020-03-17 в 21.30.34.png

Снимок экрана 2020-03-17 в 21.30.53.png

Stack trace
#0 src/XF/Mvc/Entity/Entity.php(694): XF\Mvc\Entity\Entity->_castValueToType(NULL, 'warning_points', 2, Array)
#1 src/XF/Mvc/Entity/Entity.php(1296): XF\Mvc\Entity\Entity->setAsSaved('warning_points', NULL)
#2 src/XF/Entity/User.php(1017): XF\Mvc\Entity\Entity->fastUpdate('warning_points', NULL)
#3 src/XF/Job/User.php(51): XF\Entity\User->rebuildWarningPoints()
#4 src/XF/Job/AbstractRebuildJob.php(47): XF\Job\User->rebuildById(91)
#5 src/XF/Job/Manager.php(253): XF\Job\AbstractRebuildJob->run(G)
#6 src/XF/Job/Manager.php(195): XF\Job\Manager->runJobInternal(Array, G)
#7 src/XF/Job/Manager.php(111): XF\Job\Manager->runJobEntry(Array, G)
#8 src/XF/Admin/Controller/Tools.php(120): XF\Job\Manager->runByIds(Array, 8)
#9 src/XF/Mvc/Dispatcher.php(350): XF\Admin\Controller\Tools->actionRunJob(Object(XF\Mvc\ParameterBag))
#10 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:Tools', 'RunJob', Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\Tools), NULL)
#11 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\Tools), NULL)
#12 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#13 src/XF/App.php(2184): XF\Mvc\Dispatcher->run()
#14 src/XF.php(391): XF\App->run()
#15 admin.php(13): XF::runApp('XF\\Admin\\App')
#16 {main}

-------------

Previous InvalidArgumentException: Attempted to convert NULL to integer - src/XF/Mvc/Entity/ValueFormatter.php:141
#0 src/XF/Mvc/Entity/Entity.php(736): XF\Mvc\Entity\ValueFormatter->castValueToType(NULL, 2, Array)
#1 src/XF/Mvc/Entity/Entity.php(694): XF\Mvc\Entity\Entity->_castValueToType(NULL, 'warning_points', 2, Array)
#2 src/XF/Mvc/Entity/Entity.php(1296): XF\Mvc\Entity\Entity->setAsSaved('warning_points', NULL)
#3 src/XF/Entity/User.php(1017): XF\Mvc\Entity\Entity->fastUpdate('warning_points', NULL)
#4 src/XF/Job/User.php(51): XF\Entity\User->rebuildWarningPoints()
#5 src/XF/Job/AbstractRebuildJob.php(47): XF\Job\User->rebuildById(91)
#6 src/XF/Job/Manager.php(253): XF\Job\AbstractRebuildJob->run(G)
#7 src/XF/Job/Manager.php(195): XF\Job\Manager->runJobInternal(Array, G)
#8 src/XF/Job/Manager.php(111): XF\Job\Manager->runJobEntry(Array, G)
#9 src/XF/Admin/Controller/Tools.php(120): XF\Job\Manager->runByIds(Array, 8)
#10 src/XF/Mvc/Dispatcher.php(350): XF\Admin\Controller\Tools->actionRunJob(Object(XF\Mvc\ParameterBag))
#11 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:Tools', 'RunJob', Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\Tools), NULL)
#12 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\Tools), NULL)
#13 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#14 src/XF/App.php(2184): XF\Mvc\Dispatcher->run()
#15 src/XF.php(391): XF\App->run()
#16 admin.php(13): XF::runApp('XF\\Admin\\App')
#17 {main}

Request state
array(4) {
["url"] => string(24) "/admin.php?tools/run-job"
["referrer"] => string(116) "https://*****.club/admin.php?tools/run-job&only_id=97649&_xfRedirect=%2Fadmin.php%3Ftools%2Frebuild%26success%3D1"
["_GET"] => array(1) {
["tools/run-job"] => string(0) ""
}
["_POST"] => array(3) {
["_xfRedirect"] => string(55) "https://*****.club/admin.php?tools/rebuild&success=1"
["_xfToken"] => string(8) "********"
["only_ids"] => string(5) "97649"
}
}
 
Last edited:

Xon

Well-known member
getActiveWarningPointsForUser returns null (instead of 0) if a user has no warnings. Sane solution is to add a cast to int on the return value of getActiveWarningPointsForUser.
 
Top