MissingRelationsCommand extends Command

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.

Tags
todo:

The entire logic smells fishy and needs a major overhaul.

Attributes
#[AsCommand]
'cleanup:missingrelations'
'Find all record references pointing to a non-existing record'

Table of Contents

Methods

__construct()  : mixed
configure()  : mixed
Configure the command by defining the name, options and arguments
execute()  : int
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)
findRelationsToNonExistingRecords()  : array<string|int, mixed>
Find relations pointing to non-existing records (in managed references or soft-references)
formatReferenceIndexEntryToString()  : string
Formats a sys_refindex entry to something readable
removeReference()  : void
Remove a reference to a missing record
removeReferencesToMissingRecords()  : void
Removes all references to non-existing records or offline versions
setReferenceValue()  : string|bool
Setting the value of a reference or removing it completely.
setReferenceValue_dbRels()  : string|bool
Setting a value for a reference for a DB field:
setReferenceValue_softreferences()  : string|bool
Setting a value for a soft reference token
updateReferenceIndex()  : void
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

Methods

configure()

Configure the command by defining the name, options and arguments

public configure() : mixed

execute()

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)

protected execute(InputInterface $input, OutputInterface $output) : int
Parameters
$input : InputInterface
$output : OutputInterface
Return values
int

findRelationsToNonExistingRecords()

Find relations pointing to non-existing records (in managed references or soft-references)

protected findRelationsToNonExistingRecords() : array<string|int, mixed>
Return values
array<string|int, mixed>

formatReferenceIndexEntryToString()

Formats a sys_refindex entry to something readable

protected formatReferenceIndexEntryToString(array<string|int, mixed> $record) : string
Parameters
$record : array<string|int, mixed>
Return values
string

removeReference()

Remove a reference to a missing record

protected removeReference(string $hash, string $recordReference, bool $dryRun, SymfonyStyle $io) : void
Parameters
$hash : string
$recordReference : string
$dryRun : bool
$io : SymfonyStyle

removeReferencesToMissingRecords()

Removes all references to non-existing records or offline versions

protected removeReferencesToMissingRecords(array<string|int, mixed> $offlineVersionRecords, array<string|int, mixed> $nonExistingRecords, bool $dryRun, SymfonyStyle $io) : void
Parameters
$offlineVersionRecords : array<string|int, mixed>

Contains the records of offline versions of sys_refindex which need to be removed

$nonExistingRecords : array<string|int, mixed>

Contains the records non-existing records of sys_refindex which need to be removed

$dryRun : bool

if set, the references are just displayed, but not removed

$io : SymfonyStyle

the IO object for output

setReferenceValue()

Setting the value of a reference or removing it completely.

protected setReferenceValue(string $hash) : string|bool

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

Parameters
$hash : string
Internal
Return values
string|bool

setReferenceValue_dbRels()

Setting a value for a reference for a DB field:

protected setReferenceValue_dbRels(array<string|int, mixed> $refRec, array<string|int, mixed> $itemArray, array<string|int, mixed> &$dataArray[, string $flexPointer = '' ]) : string|bool
Parameters
$refRec : array<string|int, mixed>
$itemArray : array<string|int, mixed>

Array of references from that field

$dataArray : array<string|int, mixed>

Data array in which the new value is set (passed by reference)

$flexPointer : string = ''

Flexform pointer, if in a flex form field.

Return values
string|bool

setReferenceValue_softreferences()

Setting a value for a soft reference token

protected setReferenceValue_softreferences(array<string|int, mixed> $refRec, array<string|int, mixed> $softref, array<string|int, mixed> &$dataArray[, string $flexPointer = '' ]) : string|bool
Parameters
$refRec : array<string|int, mixed>
$softref : array<string|int, mixed>

Array of soft reference occurrences

$dataArray : array<string|int, mixed>

Data array in which the new value is set (passed by reference)

$flexPointer : string = ''

Flexform pointer, if in a flex form field.

Return values
string|bool

updateReferenceIndex()

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

protected updateReferenceIndex(InputInterface $input, SymfonyStyle $io) : void
Parameters
$input : InputInterface
$io : SymfonyStyle

        
On this page

Search results