Question cron job runner issue

wmtech

Customer
We use a job runner, triggered by cron and not the usual one where the visitor object is available.

Is it possible to adapt your cron jobs to not require a visitor/user when they run? It would prevent such errors, we get sometimes when jobs are running:

Code:
In XF.php line 473:

Argument 1 passed to XF::asVisitor() must be an instance of XF\Entity\User,  null given, called in /src/addons/DBTech/eCommerce/Repository/License.php on line 408
Thanks!
 

wmtech

Customer
Sorry, there is no stack trace, because there is no error in server log. This is just the message returned by the job runner via cron.

I will try to get more information when the error triggers again.

Thanks.
 

wmtech

Customer
Now we have a stack trace, starting from the triggered runDailyCleanUp cron .

Code:
TypeError: Argument 1 passed to XF::asVisitor() must be an instance of XF\Entity\User, null given, called in src/addons/DBTech/eCommerce/Repository/License.php on line 408 src/XF.php:473
Generated by: Unknown account Jan 15, 2020 at 3:00 AM

Stack trace
#0 src/addons/DBTech/eCommerce/Repository/License.php(408): XF::asVisitor(NULL, Object(Closure))
#1 [internal function]: DBTech\eCommerce\Repository\License->DBTech\eCommerce\Repository\{closure}(Object(DBTech\eCommerce\Entity\License))
#2 src/XF/Mvc/Entity/AbstractCollection.php(189): array_filter(Array, Object(Closure))
#3 src/addons/DBTech/eCommerce/Repository/License.php(416): XF\Mvc\Entity\AbstractCollection->filter(Object(Closure))
#4 src/addons/DBTech/eCommerce/Cron/CleanUp.php(30): DBTech\eCommerce\Repository\License->sendExpiredAlerts()
#5 [internal function]: DBTech\eCommerce\Cron\CleanUp::runDailyCleanUp(Object(XF\Entity\CronEntry))

I've also checked our database. There are no licenses without a valid user_id. All have been imported from Xen Product Manager.
 

Fillip H.

Staff member
Owner
Developer
This means there's a license whose user record cannot be found. You may be able to find out which license(s) are affected by running this query:

SQL:
SELECT * FROM xf_dbtech_ecommerce_license AS license
LEFT JOIN xf_user AS user USING(user_id)
WHERE user.user_id IS NULL
 

wmtech

Customer
This means there's a license whose user record cannot be found. You may be able to find out which license(s) are affected by running this query:
Thanks. There really are some licenses with non existing users. I would have expected such licenses would be automatically deleted if the user is deleted.

Can I simply delete those licenses in the database, because deleting them from acp is not possible either?
 

Fillip H.

Staff member
Owner
Developer
You can, yes. Licenses are deleted when users are deleted, this is likely due to imported licenses for users that are not longer valid.
 

DragonByte eCommerce

XenForo 2.0.6+ XenForo 2.1.x
Seller
DragonByte Technologies
Release date
Last update
Total downloads
838
Customer rating
4.80 star(s) 5 ratings
Top