[FEATURE] Add signal to exclude tables from ReferenceIndex
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Documentation / Changelog / master / Feature-79387-AddSignalToExcludeTablesFromReferenceIndex.rst
1 .. include:: ../../Includes.txt
2
3 ==================================================================
4 Feature: #79387 - Add signal to exclude tables from ReferenceIndex
5 ==================================================================
6
7 See :issue:`79387`
8
9 Description
10 ===========
11
12 A new signal :php:`shouldExcludeTableFromReferenceIndex` is emitted in :php:`TYPO3\CMS\Core\Database\ReferenceIndex` which allows extensions to define tables
13 which should be excluded from ReferenceIndex.
14
15 Register the class which excludes tables in `ext_localconf.php`:
16
17 .. code-block:: php
18
19 $dispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
20 $dispatcher->connect(
21 \TYPO3\CMS\Core\Database\ReferenceIndex::class,
22 'shouldExcludeTableFromReferenceIndex',
23 \MyVendor\MyExtension\Slots\ReferenceIndexSlot::class,
24 'shouldExcludeTableFromReferenceIndex'
25 );
26
27 Your class could look like this:
28
29 .. code-block:: php
30
31 namespace MyVendor\MyExtension\Slot;
32
33 class ReferenceIndexSlot {
34
35 /**
36 * Exclude tables from ReferenceIndex which cannot contain a reference
37 *
38 * @param string $tableName Name of the table
39 * @param bool &$excludeTable Reference to a boolean whether to exclude the table from ReferenceIndex or not
40 */
41 public function shouldExcludeTableFromReferenceIndex($tableName, &$excludeTable) {
42 if ($tableName === 'tx_myextension_mytable') {
43 $excludeTable = true;
44 }
45 }
46
47 }
48
49 Impact
50 ======
51
52 This signal allows extensions to speed up the process of maintaining the ReferenceIndex: If an extension has tables in which by definition none of its columns
53 can contain any relations to other records it can be excluded from ReferenceIndex.
54
55 Only exclude tables from ReferenceIndex which do not contain any relations and never did since existing references won't be deleted if it is excluded! There is
56 no need to add tables without a definition in :php:`$GLOBALS['TCA]` since ReferenceIndex only handles those.
57
58 .. index:: Database