Skip to content

Instantly share code, notes, and snippets.

@froemken
Created January 28, 2021 16:21
Show Gist options
  • Save froemken/c9f24243d406b1f873ba321b72addedf to your computer and use it in GitHub Desktop.
Save froemken/c9f24243d406b1f873ba321b72addedf to your computer and use it in GitHub Desktop.
A really nasty solution to prevent call of TYPO3 Solr getAvailableSites performance issue
/**
* While copying pagetree we have to prevent calling getAvailableSites of solr, as it
* initializes ALL 300 pagetrees and load its full TS.
*/
protected function modifyRequestForSolrAndSolrfal()
{
// While copying pagetree solr will monitor various records. But without known
// rootPageUid it will call getAllSites() which will build the TS for all sites.
// We set monitored tables to invalidTable, so NO table will be monitored.
$solrExtConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['solr']);
$solrExtConf['useConfigurationMonitorTables'] = 'invalidTable';
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['solr'] = serialize($solrExtConf);
// While copying pagetree solrfal will check, if a record is used on another pagetree.
// To prevent that, we have to add all known tables temporary to siteExclusiveRecordTables
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$connection = $connectionPool->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME);
$tables = $connection->getSchemaManager()->listTableNames();
$solrfalExtConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['solrfal']);
$solrfalExtConf['siteExclusiveRecordTables'] = implode(',', $tables);
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['solrfal'] = serialize($solrfalExtConf);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment