<?php
namespace wcf\action;
use wcf\system\background\BackgroundQueueHandler;

/**
 * Performs background queue jobs.
 * 
 * @author	Tim Duesterhus
 * @copyright	2001-2019 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	WoltLabSuite\Core\Action
 * @since	3.0
 */
class BackgroundQueuePerformAction extends AbstractAction {
	/**
	 * number of jobs that will be processed per invocation
	 * @var integer
	 */
	public static $jobsPerRun = 5;
	
	/**
	 * @inheritDoc
	 */
	public function execute() {
		parent::execute();
		
		header('Content-type: application/json');
		for ($i = 0; $i < self::$jobsPerRun; $i++) {
			if (BackgroundQueueHandler::getInstance()->performNextJob() === false) {
				// there were no more jobs
				break;
			}
		}
		echo BackgroundQueueHandler::getInstance()->getRunnableCount();
		exit;
	}
}

<?php
namespace wcf\action;
use wcf\system\background\BackgroundQueueHandler;
use wcf\system\WCF;

/**
 * Performs background queue jobs.
 * 
 * @author	Tim Duesterhus
 * @copyright	2001-2019 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	WoltLabSuite\Core\Action
 * @since	3.0
 */
class BackgroundQueuePerformAction extends AbstractAction {
	/**
	 * number of jobs that will be processed per invocation
	 * @var integer
	 */
	public static $jobsPerRun = 5;
	
	/**
	 * @inheritDoc
	 */
	public function execute() {
		parent::execute();
		
		header('Content-type: application/json');
		for ($i = 0; $i < self::$jobsPerRun; $i++) {
			if (BackgroundQueueHandler::getInstance()->performNextJob() === false) {
				// there were no more jobs
				break;
			}
		}
		echo BackgroundQueueHandler::getInstance()->getRunnableCount();
		if (WCF::getSession()->isFirstVisit() && !WCF::getUser()->userID) {
			WCF::getSession()->delete();
		}
		exit;
	}
}

Delete firstVisit = true, userID = 0 sessions after processing background queue
Delete firstVisit = true, userID = 0 sessions after processing background queue

These sessions most likely stem from a script / cronjob that is set-up
to regularly request the background queue to ensure it does not fill up
in periods of low user activity. They “fill up” the session table, skew
the user online statistics and are not going to be re-used.
