Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/Event/Subscriber/TimedPublishSubscriber.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

declare(strict_types=1);
Expand All @@ -7,7 +7,9 @@
use Bolt\Doctrine\TablePrefixTrait;
use Bolt\Entity\Content;
use Carbon\Carbon;
use Doctrine\DBAL\Types\Types;
use Doctrine\Persistence\ManagerRegistry;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Throwable;
Expand All @@ -20,13 +22,15 @@

private object $defaultConnection;
private string $tablePrefix;
private LoggerInterface $logger;

public function __construct($tablePrefix, ManagerRegistry $managerRegistry)
public function __construct($tablePrefix, ManagerRegistry $managerRegistry, LoggerInterface $logger)
{
$this->defaultConnection = $managerRegistry->getConnection('default');
$this->tablePrefix = $this
->setTablePrefixes($tablePrefix, $managerRegistry)
->getTablePrefix($managerRegistry->getManager('default'));
$this->logger = $logger;
}

/**
Expand All @@ -49,10 +53,11 @@
);

try {
$conn->executeUpdate($queryPublish, [':now' => $now]);
$conn->executeUpdate($queryDepublish, [':now' => $now]);
} catch (Throwable) {
$conn->executeStatement($queryPublish, ['now' => $now], ['now' => Types::DATETIME_MUTABLE]);

Check failure on line 56 in src/Event/Subscriber/TimedPublishSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.2

Call to an undefined method object::executeStatement().

Check failure on line 56 in src/Event/Subscriber/TimedPublishSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.3

Call to an undefined method object::executeStatement().

Check failure on line 56 in src/Event/Subscriber/TimedPublishSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.4

Call to an undefined method object::executeStatement().
$conn->executeStatement($queryDepublish, ['now' => $now], ['now' => Types::DATETIME_MUTABLE]);

Check failure on line 57 in src/Event/Subscriber/TimedPublishSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.2

Call to an undefined method object::executeStatement().

Check failure on line 57 in src/Event/Subscriber/TimedPublishSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.3

Call to an undefined method object::executeStatement().

Check failure on line 57 in src/Event/Subscriber/TimedPublishSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.4

Call to an undefined method object::executeStatement().
} catch (Throwable $exception) {
// Fail silently, output user-friendly exception elsewhere.
Comment thread
Senne marked this conversation as resolved.
Outdated
$this->logger->debug('Failed to publish/depublish timed content', ['exception' => $exception]);
}
}

Expand Down
Loading