Add Rebuild Entries job

This commit is contained in:
2026-07-02 18:06:32 +02:00
parent afd0f434db
commit 86f97c3103
12 changed files with 200 additions and 12 deletions

View File

@@ -6,17 +6,17 @@ use XF\Service\AbstractService;
class BotService extends AbstractService
{
protected string $dbPath;
protected ?string $dbPath;
protected ?\PDO $pdo = null;
protected function setup()
{
$this->dbPath = \XF::config('discord_db_path');
$this->dbPath = \XF::config('discord_db_path') ?? null;
}
protected function getDb(): \PDO
protected function getDb(): ?\PDO
{
if (!$this->pdo) {
if (!$this->pdo && $this->dbPath) {
$this->pdo = new \PDO("sqlite:" . $this->dbPath);
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$this->pdo->exec('PRAGMA journal_mode=WAL;');
@@ -29,6 +29,8 @@ class BotService extends AbstractService
{
try {
$db = $this->getDb();
if( !$db )
return false;
$stmt = $db->prepare("INSERT INTO actions (action, data) VALUES (:action, :data)");
return $stmt->execute([