Skip to content

Commit 342d224

Browse files
alongoszandrerom
authored andcommitted
EZP-25756: Can't index data in solrBundle (#47)
1 parent 5dacd67 commit 342d224

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

bundle/Command/SolrCreateIndexCommand.php

+14-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Console\Output\OutputInterface;
1616
use Symfony\Component\Console\Input\InputArgument;
1717
use eZ\Publish\SPI\Persistence\Content\ContentInfo;
18+
use eZ\Publish\Core\Base\Exceptions\NotFoundException;
1819
use EzSystems\EzPlatformSolrSearchEngine\Handler as SolrSearchEngineHandler;
1920
use RuntimeException;
2021
use PDO;
@@ -78,18 +79,26 @@ protected function execute(InputInterface $input, OutputInterface $output)
7879
$progress = $this->getHelperSet()->get('progress');
7980
$progress->start($output, $totalCount);
8081
$i = 0;
82+
$logger = $this->getContainer()->get('logger');
83+
/* @var \Psr\Log\LoggerInterface $logger */
8184
do {
8285
$contentObjects = array();
8386

8487
for ($k = 0; $k <= $bulkCount; ++$k) {
8588
if (!$row = $stmt->fetch(PDO::FETCH_ASSOC)) {
8689
break;
8790
}
88-
89-
$contentObjects[] = $persistenceHandler->contentHandler()->load(
90-
$row['id'],
91-
$row['current_version']
92-
);
91+
try {
92+
$contentObjects[] = $persistenceHandler->contentHandler()->load(
93+
$row['id'],
94+
$row['current_version']
95+
);
96+
} catch (NotFoundException $e) {
97+
$progress->clear();
98+
$output->write("\r"); // get rid of padding (side effect of displaying progress bar)
99+
$logger->warning("Could not load current version of Content with id ${row['id']}, so skipped for indexing. Full exception: " . $e->getMessage());
100+
$progress->display();
101+
}
93102
}
94103

95104
if (!empty($contentObjects)) {

lib/Handler.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,11 @@ public function bulkIndexContent(array $contentObjects)
246246
$documents = array();
247247

248248
foreach ($contentObjects as $content) {
249-
$documents[] = $this->mapper->mapContentBlock($content);
249+
try {
250+
$documents[] = $this->mapper->mapContentBlock($content);
251+
} catch (NotFoundException $ex) {
252+
// ignore content objects without assigned state id
253+
}
250254
}
251255

252256
if (!empty($documents)) {

0 commit comments

Comments
 (0)