Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions config/constants.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@
? getenv('VUFIND_CACHE_DIR')
: (strlen(LOCAL_OVERRIDE_DIR) > 0 ? LOCAL_OVERRIDE_DIR . '/cache' : ''))
);

// Define database datetime format
defined('VUFIND_DATABASE_DATETIME_FORMAT') || define('VUFIND_DATABASE_DATETIME_FORMAT', 'Y-m-d H:i:s');
2 changes: 1 addition & 1 deletion module/VuFind/src/VuFind/Crypt/SecretCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getSearchUnsubscribeSecret(SearchEntityInterface $search): strin
$data = [
'id' => $search->getId(),
'user_id' => $user->getId(),
'created' => $user->getCreated()->format('Y-m-d H:i:s'),
'created' => $user->getCreated()->format(VUFIND_DATABASE_DATETIME_FORMAT),
];
return $this->hmac->generate(array_keys($data), $data);
}
Expand Down
3 changes: 2 additions & 1 deletion module/VuFind/src/VuFind/Db/Feature/DateTimeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ trait DateTimeTrait
protected function getNullableDateTimeFromNonNullable(DateTime $date): ?DateTime
{
// Compare strings to avoid trouble with time zones:
return $date->format('Y-m-d H:i:s') !== $this->getUnassignedDefaultDateTime()->format('Y-m-d H:i:s')
return $date->format(VUFIND_DATABASE_DATETIME_FORMAT)
!== $this->getUnassignedDefaultDateTime()->format(VUFIND_DATABASE_DATETIME_FORMAT)
? $date
: null;
}
Expand Down
2 changes: 1 addition & 1 deletion module/VuFind/src/VuFind/Db/Service/AccessTokenService.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function deleteExpired(DateTime $dateLimit, ?int $limit = null): int
$subQueryBuilder->select('CONCAT(a.id, a.type)')
->from(AccessTokenEntityInterface::class, 'a')
->where('a.created < :latestCreated')
->setParameter('latestCreated', $dateLimit->format('Y-m-d H:i:s'));
->setParameter('latestCreated', $dateLimit->format(VUFIND_DATABASE_DATETIME_FORMAT));
if ($limit) {
$subQueryBuilder->setMaxResults($limit);
}
Expand Down
2 changes: 1 addition & 1 deletion module/VuFind/src/VuFind/Db/Service/AuthHashService.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function deleteExpired(DateTime $dateLimit, ?int $limit = null): int
$subQueryBuilder->select('ah.id')
->from(AuthHashEntityInterface::class, 'ah')
->where('ah.created < :dateLimit')
->setParameter('dateLimit', $dateLimit->format('Y-m-d H:i:s'));
->setParameter('dateLimit', $dateLimit->format(VUFIND_DATABASE_DATETIME_FORMAT));
if ($limit) {
$subQueryBuilder->setMaxResults($limit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ protected function createTokenId(): string
*/
protected function createExpiryDateTime(): \DateTimeImmutable
{
return new \DateTimeImmutable(date('Y-m-d H:i:s', strtotime('now+1hour')));
return new \DateTimeImmutable(date(VUFIND_DATABASE_DATETIME_FORMAT, strtotime('now+1hour')));
Comment thread
demiankatz marked this conversation as resolved.
Outdated
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ function (
$resumptionToken = $this->createResumptionToken($request, $nextCursor, $nextCursorMark);
$response['resumptionToken'] = [
'token' => $resumptionToken->getToken(),
'expires' => $resumptionToken->getExpiry()->format('Y-m-d H:i:s'),
'expires' => $resumptionToken->getExpiry()->format(VUFIND_DATABASE_DATETIME_FORMAT),
];
}
return $response;
Expand Down
1 change: 1 addition & 0 deletions tests/phpstan-constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
const DEFAULT_SEARCH_BACKEND = 'Solr';
const LOCAL_CACHE_DIR = './local';
const LOCAL_OVERRIDE_DIR = '.';
const VUFIND_DATABASE_DATETIME_FORMAT = 'Y-m-d H:i:s';