<?php

namespace wcf\system\cronjob;

use wcf\data\cronjob\Cronjob;
use wcf\system\WCF;

/**
 * Updates the last activity timestamp in the user table.
 *
 * @author  Marcel Werk
 * @copyright   2001-2021 WoltLab GmbH
 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package WoltLabSuite\Core\System\Cronjob
 */
class LastActivityCronjob extends AbstractCronjob
{
    /**
     * @inheritDoc
     */
    public function execute(Cronjob $cronjob)
    {
        parent::execute($cronjob);

        $sql = "UPDATE  wcf1_user user_table,
                        wcf1_session session
                SET     user_table.lastActivityTime = session.lastActivityTime
                WHERE   user_table.userID = session.userID
                    AND session.userID IS NOT NULL";
        $statement = WCF::getDB()->prepare($sql);
        $statement->execute();
    }
}

<?php

namespace wcf\system\cronjob;

use wcf\data\cronjob\Cronjob;
use wcf\system\WCF;

/**
 * Updates the last activity timestamp in the user table.
 *
 * @author  Marcel Werk
 * @copyright   2001-2021 WoltLab GmbH
 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package WoltLabSuite\Core\System\Cronjob
 */
class LastActivityCronjob extends AbstractCronjob
{
    /**
     * @inheritDoc
     */
    public function execute(Cronjob $cronjob)
    {
        parent::execute($cronjob);

        $sql = "UPDATE  wcf" . WCF_N . "_user user_table,
                        wcf" . WCF_N . "_session session
                SET     user_table.lastActivityTime = session.lastActivityTime
                WHERE   user_table.userID = session.userID
                    AND session.userID IS NOT NULL";
        $statement = WCF::getDB()->prepareStatement($sql);
        $statement->execute();
    }
}

--- 
+++ 
@@ -22,12 +22,12 @@
     {
         parent::execute($cronjob);
 
-        $sql = "UPDATE  wcf" . WCF_N . "_user user_table,
-                        wcf" . WCF_N . "_session session
+        $sql = "UPDATE  wcf1_user user_table,
+                        wcf1_session session
                 SET     user_table.lastActivityTime = session.lastActivityTime
                 WHERE   user_table.userID = session.userID
                     AND session.userID IS NOT NULL";
-        $statement = WCF::getDB()->prepareStatement($sql);
+        $statement = WCF::getDB()->prepare($sql);
         $statement->execute();
     }
 }
Use `->prepare()` instead of `->prepareStatement() in LastActivityCronjob
