Project

General

Profile

Actions

Bug #106211

closed

'tstamp' is hardcoded

Added by Claus Harup 2 months ago. Updated 2 months ago.

Status:
Rejected
Priority:
Should have
Assignee:
Category:
Linkvalidator
Target version:
Start date:
2025-02-19
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

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']....

Actions #1

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

Actions #2

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!!

Actions #3

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

Actions #4

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.... :-(

Actions #5

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;
        }

Actions #6

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)

Actions #7

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;
            }
        }
        ...
Actions #8

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!

Actions #9

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.

Actions #10

Updated by Claus Harup 2 months ago

Everything works like a charm using composer patch!!!

Actions

Also available in: Atom PDF