‪TYPO3CMS  ‪main
TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand Class Reference
Inheritance diagram for TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand:

Public Member Functions

 __construct (private readonly ConnectionPool $connectionPool, private readonly ReferenceIndex $referenceIndex,)
 
 configure ()
 

Protected Member Functions

 execute (InputInterface $input, OutputInterface $output)
 
 updateReferenceIndex (InputInterface $input, SymfonyStyle $io)
 
 findRelationsToNonExistingRecords ()
 
 removeReferencesToMissingRecords (array $offlineVersionRecords, array $nonExistingRecords, bool $dryRun, SymfonyStyle $io)
 
 removeReference (string $hash, string $recordReference, bool $dryRun, SymfonyStyle $io)
 
 formatReferenceIndexEntryToString (array $record)
 
 setReferenceValue (string $hash)
 
 setReferenceValue_dbRels (array $refRec, array $itemArray, array &$dataArray, string $flexPointer='')
 
 setReferenceValue_softreferences (array $refRec, array $softref, array &$dataArray, string $flexPointer='')
 

Detailed Description

Finds references and soft-references to

  • ‪records which are marked as deleted (e.g. still in the system as reminder)
  • ‪offline versions (references should never point to offline versions)
  • ‪non-existing records (records which have been deleted not via DataHandler)

The later (non-soft-reference variants) can be automatically fixed by simply removing the references from the refindex.

Todo:
‪: The entire logic smells fishy and needs a major overhaul.

Definition at line 49 of file MissingRelationsCommand.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand::__construct ( private readonly ConnectionPool  $connectionPool,
private readonly ReferenceIndex  $referenceIndex 
)

Definition at line 51 of file MissingRelationsCommand.php.

Member Function Documentation

◆ configure()

TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand::configure ( )

Configure the command by defining the name, options and arguments

Definition at line 61 of file MissingRelationsCommand.php.

◆ execute()

TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand::execute ( InputInterface  $input,
OutputInterface  $output 
)
protected

Executes the command to

  • ‪optionally update the reference index (to have clean data)
  • ‪find data in sys_refindex (softrefs and regular references) where the reference points to a non-existing record or offline version
  • ‪remove these files if –dry-run is not set (not possible for refindexes)

Definition at line 110 of file MissingRelationsCommand.php.

References $output, TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand\findRelationsToNonExistingRecords(), TYPO3\CMS\Core\Core\Bootstrap\initializeBackendAuthentication(), TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand\removeReferencesToMissingRecords(), and TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand\updateReferenceIndex().

◆ findRelationsToNonExistingRecords()

TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand::findRelationsToNonExistingRecords ( )
protected

◆ formatReferenceIndexEntryToString()

TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand::formatReferenceIndexEntryToString ( array  $record)
protected

Formats a sys_refindex entry to something readable

Definition at line 378 of file MissingRelationsCommand.php.

References TYPO3\CMS\Webhooks\Message\$record.

Referenced by TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand\findRelationsToNonExistingRecords().

◆ removeReference()

TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand::removeReference ( string  $hash,
string  $recordReference,
bool  $dryRun,
SymfonyStyle  $io 
)
protected

◆ removeReferencesToMissingRecords()

TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand::removeReferencesToMissingRecords ( array  $offlineVersionRecords,
array  $nonExistingRecords,
bool  $dryRun,
SymfonyStyle  $io 
)
protected

Removes all references to non-existing records or offline versions

Parameters
array$offlineVersionRecords‪Contains the records of offline versions of sys_refindex which need to be removed
array$nonExistingRecords‪Contains the records non-existing records of sys_refindex which need to be removed
bool$dryRun‪if set, the references are just displayed, but not removed
SymfonyStyle$io‪the IO object for output

Definition at line 333 of file MissingRelationsCommand.php.

References TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand\removeReference().

Referenced by TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand\execute().

◆ setReferenceValue()

TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand::setReferenceValue ( string  $hash)
protected

Setting the value of a reference or removing it completely. Usage: For lowlevel clean up operations! WARNING: With this you can set values that are not allowed in the database since it will bypass all checks for validity! Hence it is targeted at clean-up operations. Please use DataHandler in the usual ways if you wish to manipulate references. Since this interface allows updates to soft reference values (which DataHandler does not directly) you may like to use it for that as an exception to the warning above. Notice; If you want to remove multiple references from the same field, you MUST start with the one having the highest sorting number. If you don't the removal of a reference with a lower number will recreate an index in which the remaining references in that field has new hash-keys due to new sorting numbers - and you will get errors for the remaining operations which cannot find the hash you feed it! To ensure proper working only admin-BE_USERS in live workspace should use this function

Definition at line 402 of file MissingRelationsCommand.php.

References $GLOBALS, TYPO3\CMS\Webhooks\Message\$record, TYPO3\CMS\Core\Database\Connection\PARAM_INT, TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand\setReferenceValue_dbRels(), and TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand\setReferenceValue_softreferences().

Referenced by TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand\removeReference().

◆ setReferenceValue_dbRels()

TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand::setReferenceValue_dbRels ( array  $refRec,
array  $itemArray,
array &  $dataArray,
string  $flexPointer = '' 
)
protected

Setting a value for a reference for a DB field:

Parameters
array$itemArray‪Array of references from that field
array$dataArray‪Data array in which the new value is set (passed by reference)
string$flexPointer‪Flexform pointer, if in a flex form field.

Definition at line 506 of file MissingRelationsCommand.php.

References TYPO3\CMS\Core\Utility\ArrayUtility\setValueByPath().

Referenced by TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand\setReferenceValue().

◆ setReferenceValue_softreferences()

TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand::setReferenceValue_softreferences ( array  $refRec,
array  $softref,
array &  $dataArray,
string  $flexPointer = '' 
)
protected

Setting a value for a soft reference token

Parameters
array$softref‪Array of soft reference occurrences
array$dataArray‪Data array in which the new value is set (passed by reference)
string$flexPointer‪Flexform pointer, if in a flex form field.

Definition at line 540 of file MissingRelationsCommand.php.

References TYPO3\CMS\Core\Utility\ArrayUtility\setValueByPath().

Referenced by TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand\setReferenceValue().

◆ updateReferenceIndex()

TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand::updateReferenceIndex ( InputInterface  $input,
SymfonyStyle  $io 
)
protected

Function to update the reference index

  • ‪if the option –update-refindex is set, do it
  • ‪otherwise, if in interactive mode (not having -n set), ask the user
  • ‪otherwise assume everything is fine

Definition at line 196 of file MissingRelationsCommand.php.

Referenced by TYPO3\CMS\Lowlevel\Command\MissingRelationsCommand\execute().