Bug #106211
closed'tstamp' is hardcoded
0%
Description
In LinkAnalyzer.php function recheckLinks 'tstamp' is hardcoded.
$row = $queryBuilder->select('uid', 'pid', $GLOBALS['TCA'][$table]['ctrl']['label'], $field, 'tstamp')
->from($table)
->where(
$queryBuilder->expr()->eq(
'uid',
$queryBuilder->createNamedParameter($recordUid, Connection::PARAM_INT)
)
)
->executeQuery()
->fetchAssociative();
if (!$row) {
// missing record: remove existing links
$this->brokenLinkRepository->removeBrokenLinksForRecord($table, $recordUid);
return;
}
if (($row['tstamp'] ?? 0) && $timestamp && ((int)($row['tstamp']) < $timestamp)) {
// timestamp has not changed: no need to recheck
return;
}
'tstamp' should be derived from TCA['ctrl']['tstamp']....
Updated by Georg Ringer 2 months ago
- Assignee set to Georg Ringer
fixed in 13.4 at least, will check if we backport that to 12
Updated by Claus Harup 2 months ago
Georg Ringer wrote in #note-1:
fixed in 13.4 at least, will check if we backport that to 12
Brillant!!
Updated by Georg Ringer 2 months ago
- Status changed from New to Rejected
just checked with benni. There are a lot of places where this is hardcoded and this is fixed in 13 using the schema API.
therefore we won't fix it in 12.
hope that is still ok for you
Updated by Claus Harup 2 months ago
Georg Ringer wrote in #note-3:
just checked with benni. There are a lot of places where this is hardcoded and this is fixed in 13 using the schema API.
therefore we won't fix it in 12.hope that is still ok for you
Unfortunately I cannot add the link validator functionality to my clients.... :-(
Updated by Claus Harup 2 months ago
This would fix it :-)
$tstamp = $GLOBALS['TCA'][$table]['ctrl']['tstamp'];
$row = $queryBuilder->select('uid', 'pid', $GLOBALS['TCA'][$table]['ctrl']['label'], $field, $tstamp)
->from($table)
->where(
$queryBuilder->expr()->eq(
'uid',
$queryBuilder->createNamedParameter($recordUid, Connection::PARAM_INT)
)
)
->executeQuery()
->fetchAssociative();
if (!$row) {
// missing record: remove existing links
$this->brokenLinkRepository->removeBrokenLinksForRecord($table, $recordUid);
return;
}
if (($row[$tstamp] ?? 0) && $timestamp && ((int)($row[$tstamp]) < $timestamp)) {
// timestamp has not changed: no need to recheck
return;
}
Updated by Garvin Hicking 2 months ago
@Claus Harup @Claus Harup (that would only work when 'tstamp' is really available, it would still fail on tables having no timestamp at all)
Updated by Claus Harup 2 months ago
There you go :-)
...
$selects = ['uid', 'pid', $GLOBALS['TCA'][$table]['ctrl']['label'], $field];
$tstamp = $GLOBALS['TCA'][$table]['ctrl']['tstamp'] ?? false;
if ($tstamp) {
$selects[] = $tstamp;
}
$row = $queryBuilder->select(...$selects)
->from($table)
->where(
$queryBuilder->expr()->eq(
'uid',
$queryBuilder->createNamedParameter($recordUid, Connection::PARAM_INT)
)
)
->executeQuery()
->fetchAssociative();
if (!$row) {
// missing record: remove existing links
$this->brokenLinkRepository->removeBrokenLinksForRecord($table, $recordUid);
return;
}
if ($tstamp) {
if (($row[$tstamp] ?? 0) && $timestamp && ((int)($row[$tstamp]) < $timestamp)) {
// timestamp has not changed: no need to recheck
return;
}
}
...
Updated by Garvin Hicking 2 months ago
Great, thank you for sharing this so that users affected by this in v12 could patch it like this!
Updated by Georg Ringer 2 months ago
just a final comment: use XCLASS or composer patches to provide that change to your site. or update to v13 in the long run.
Updated by Claus Harup 2 months ago
Everything works like a charm using composer patch!!!