Skip to content

Commit

Permalink
Add debug logger for index process
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Aug 12, 2021
1 parent 8414a77 commit 1705a56
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Classes/Service/IndexerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@
use HDNET\Calendarize\Utility\DateTimeUtility;
use HDNET\Calendarize\Utility\HelperUtility;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\Backend;

/**
* Index the given events.
*/
class IndexerService extends AbstractService
class IndexerService extends AbstractService implements LoggerAwareInterface
{
use LoggerAwareTrait;

/**
* Index table name.
*/
Expand Down Expand Up @@ -61,6 +67,8 @@ public function __construct(
*/
public function reindexAll()
{
$this->logger->debug('Start reindex ALL process');

$this->eventDispatcher->dispatch(new IndexAllEvent($this, IndexAllEvent::POSITION_PRE));

$this->removeInvalidConfigurationIndex();
Expand Down Expand Up @@ -105,6 +113,8 @@ public function reindexAll()
*/
public function reindex(string $configurationKey, string $tableName, int $uid)
{
$this->logger->debug('Start reindex SINGLE ' . $tableName . ':' . $uid);

$this->eventDispatcher->dispatch(new IndexSingleEvent($configurationKey, $tableName, $uid, $this, IndexSingleEvent::POSITION_PRE));

$this->removeInvalidConfigurationIndex();
Expand Down Expand Up @@ -147,7 +157,12 @@ public function getIndexCount(string $tableName, $uid): int
{
// Note: "uid" could be e.g. NEW6273482 in DataHandler process
if (MathUtility::canBeInterpretedAsInteger($uid)) {
return (int)$this->getCurrentItems($tableName, (int)$uid)->rowCount();
$workspace = 0;
if ($GLOBALS['BE_USER'] instanceof BackendUserAuthentication) {
$workspace = (int)$GLOBALS['BE_USER']->workspace;
}

return (int)$this->getCurrentItems($tableName, (int)$uid, $workspace)->rowCount();
}

return 0;
Expand Down Expand Up @@ -201,6 +216,8 @@ protected function updateIndex(string $configurationKey, string $tableName, int
$workspace = isset($rawRecord['t3ver_wsid']) ? (int)$rawRecord['t3ver_wsid'] : 0;
$origId = isset($rawRecord['t3ver_oid']) ? (int)$rawRecord['t3ver_oid'] : 0;

$this->logger->debug('Update index of ' . $tableName . ':' . $uid . ' in workspace ' . $workspace);

if ($workspace && $origId) {
// Remove all entries in current workspace that are related to the current item
HelperUtility::getDatabaseConnection(self::TABLE_NAME)->delete(self::TABLE_NAME, [
Expand Down Expand Up @@ -365,6 +382,8 @@ protected function removeInvalidRecordIndex($tableName)
*/
protected function removeInvalidConfigurationIndex()
{
$this->logger->debug('Log invalid index items of old configurations');

$db = HelperUtility::getDatabaseConnection(self::TABLE_NAME);
$q = $db->createQueryBuilder();

Expand Down
7 changes: 7 additions & 0 deletions Documentation/AdministratorManual/Workspaces/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ Selection
---------

The "reindexAll" (via Scheduler) but also the single index process take care, that the Live version is always the first in the index process and after the Live Index the Workspace records are created.


Scheduler
---------

I suggest to enable the "reindex all" command in the scheduler to cleanup the index in the right way.

0 comments on commit 1705a56

Please sign in to comment.