[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] console index rebuild: add ability to skip error tracking for large...
"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <693d668618c4a_2a75a1f4817f6@gitlab-sidekiq-low-urgency-cpu-bound-v2-64d4768b4d-6hkph.mail> |
Victor Emanouilov pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
a6dccf45 by Victor Emanouilov at 2025-12-13T15:13:34+02:00
[FIX] console index rebuild: add ability to skip error tracking for large indexes where log file is enough
- - - - -
4 changed files:
- lib/core/Search/Indexer.php
- lib/core/Search/SearchIndexRebuilder.php
- lib/core/Tiki/Command/IndexRebuildCommand.php
- lib/search/searchlib-unified.php
Changes:
=====================================
lib/core/Search/Indexer.php
=====================================
@@ -21,6 +21,7 @@ class Search_Indexer
private $cacheGlobals = null;
private $cacheTypes = [];
private $cacheErrors = [];
+ private $errorTrackingEnabled = true;
private $stats;
private $contentFilters = [];
@@ -118,6 +119,11 @@ class Search_Indexer
$this->contentFilters[] = $filter;
}
+ public function setErrorTrackingEnabled($errorTrackingEnabled)
+ {
+ $this->errorTrackingEnabled = $errorTrackingEnabled;
+ }
+
/**
* Rebuild the entire index.
*
@@ -232,7 +238,9 @@ class Search_Indexer
$e->getMessage()
);
Feedback::error($msg);
- TikiLib::lib('errortracking')->captureException($e);
+ if ($this->errorTrackingEnabled) {
+ TikiLib::lib('errortracking')->captureException($e);
+ }
}
foreach ($this->cacheErrors as $err) {
$this->log->error($err['error'] . ': ' . $err['errstr'], [
@@ -240,8 +248,10 @@ class Search_Indexer
'file' => $err['errfile'],
'line' => $err['errline'],
]);
- $e = new ErrorException($err['errstr'], 0, $err['errno'], $err['errfile'], $err['errline']);
- TikiLib::lib('errortracking')->captureException($e);
+ if ($this->errorTrackingEnabled) {
+ $e = new ErrorException($err['errstr'], 0, $err['errno'], $err['errfile'], $err['errline']);
+ TikiLib::lib('errortracking')->captureException($e);
+ }
}
$this->cacheErrors = [];
// log file display feedback messages after each document line to make it easier to track
=====================================
lib/core/Search/SearchIndexRebuilder.php
=====================================
@@ -30,7 +30,7 @@ class SearchIndexRebuilder
* @param mixed $progress Progress bar object for console output (optional)
* @return array|null Statistics from rebuild if executed directly, null if queued
*/
- public function executeOrQueueIndexRebuild(int $logLevel = 0, bool $cleanupErrors = true, $progress = null): ?array
+ public function executeOrQueueIndexRebuild(int $logLevel = 0, bool $cleanupErrors = true, $progress = null, $skipErrorTracking = false): ?array
{
global $prefs;
@@ -66,7 +66,7 @@ class SearchIndexRebuilder
return null; // Indicates task was queued
} else {
// Execute directly
- return $this->rebuildIndex($logLevel, $cleanupErrors, $progress);
+ return $this->rebuildIndex($logLevel, $cleanupErrors, $progress, $skipErrorTracking);
}
}
@@ -79,7 +79,7 @@ class SearchIndexRebuilder
* @param mixed $progress Progress bar object for console output (optional)
* @return array|null Statistics from the rebuild operation
*/
- public function rebuildIndex(int $logLevel = 0, bool $cleanupErrors = true, $progress = null): ?array
+ public function rebuildIndex(int $logLevel = 0, bool $cleanupErrors = true, $progress = null, $skipErrorTracking = false): ?array
{
global $prefs;
@@ -94,7 +94,7 @@ class SearchIndexRebuilder
$unifiedsearchlib = TikiLib::lib('unifiedsearch');
// Rebuild the main search index
- $stat = $unifiedsearchlib->rebuild($logLevel, false, $progress);
+ $stat = $unifiedsearchlib->rebuild($logLevel, false, $progress, $skipErrorTracking);
// Handle progress bar if provided
if ($progress) {
=====================================
lib/core/Tiki/Command/IndexRebuildCommand.php
=====================================
@@ -43,6 +43,12 @@ class IndexRebuildCommand extends Command
'p',
InputOption::VALUE_NONE,
'Show progress bar'
+ )
+ ->addOption(
+ 'skip-error-tracking',
+ null,
+ InputOption::VALUE_NONE,
+ 'Skip Tiki error tracking and only log errors to log file (if enabled). Useful if you rebuild generates a lot of noise in your external error tracking system.'
);
}
@@ -130,10 +136,11 @@ class IndexRebuildCommand extends Command
$progress->setMessage(tr('Rebuilding...'));
$progress->start();
}
+ $skipErrorTracking = $input->getOption('skip-error-tracking') ? true : false;
// Use shared service to rebuild index directly (console commands always execute directly)
$searchIndexRebuilder = new SearchIndexRebuilder();
- $result = $searchIndexRebuilder->rebuildIndex($log, false, $progress);
+ $result = $searchIndexRebuilder->rebuildIndex($log, false, $progress, $skipErrorTracking);
\Feedback::printToConsole($output, $cron);
=====================================
lib/search/searchlib-unified.php
=====================================
@@ -169,7 +169,7 @@ class UnifiedSearchLib
* @return array|bool
* @throws Exception
*/
- public function rebuild($loggit = 0, $fallback = false, $progress = null)
+ public function rebuild($loggit = 0, $fallback = false, $progress = null, $skipErrorTracking = false)
{
global $prefs;
$engineResults = null;
@@ -263,6 +263,7 @@ class UnifiedSearchLib
try {
$indexDecorator = new Search_Index_TypeAnalysisDecorator($index);
$indexer = $this->buildIndexer($indexDecorator, $loggit);
+ $indexer->setErrorTrackingEnabled(! $skipErrorTracking);
$lastStats = $tikilib->get_preference('unified_last_rebuild_stats_' . $prefs['unified_engine'], [], true);
$stat = $tikilib->allocate_extra(
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/a6dccf45ecea1ea227e3d1def375c6db9da7d000
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/a6dccf45ecea1ea227e3d1def375c6db9da7d000
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs