Code Duplication    Length = 26-27 lines in 2 locations

eZ/Publish/Core/Search/Legacy/Content/Indexer.php 1 location

@@ 51-77 (lines=27) @@
48
        $progress->start($totalCount);
49
50
        $i = 0;
51
        do {
52
            $contentObjects = [];
53
            for ($k = 0; $k <= $iterationCount; ++$k) {
54
                if (!$row = $stmt->fetch(PDO::FETCH_ASSOC)) {
55
                    break;
56
                }
57
                try {
58
                    $contentObjects[] = $this->persistenceHandler->contentHandler()->load(
59
                        $row['id'],
60
                        $row['current_version']
61
                    );
62
                } catch (NotFoundException $e) {
63
                    $this->logWarning($progress, "Could not load current version of Content with id ${row['id']}, so skipped for indexing. Full exception: " . $e->getMessage());
64
                }
65
            }
66
67
            foreach ($contentObjects as $content) {
68
                try {
69
                    $this->searchHandler->indexContent($content);
70
                } catch (NotFoundException $e) {
71
                    // Ignore content objects that have some sort of missing data on it
72
                    $this->logWarning($progress, 'Content with id ' . $content->versionInfo->id . ' has missing data, so skipped for indexing. Full exception: ' . $e->getMessage());
73
                }
74
            }
75
76
            $progress->advance($k);
77
        } while (($i += $iterationCount) < $totalCount);
78
        $progress->finish();
79
        $output->writeln('');
80

eZ/Bundle/EzPublishLegacySearchEngineBundle/Command/CreateIndexCommand.php 1 location

@@ 122-147 (lines=26) @@
119
        $progress = $this->getHelperSet()->get('progress');
120
        $progress->start($output, $totalCount);
121
        $i = 0;
122
        do {
123
            $contentObjects = [];
124
            for ($k = 0; $k <= $bulkCount; ++$k) {
125
                if (!$row = $stmt->fetch(PDO::FETCH_ASSOC)) {
126
                    break;
127
                }
128
                try {
129
                    $contentObjects[] = $this->persistenceHandler->contentHandler()->load(
130
                        $row['id'],
131
                        $row['current_version']
132
                    );
133
                } catch (NotFoundException $e) {
134
                    $this->logWarning($output, $progress, "Could not load current version of Content with id ${row['id']}, so skipped for indexing. Full exception: " . $e->getMessage());
135
                }
136
            }
137
138
            $this->searchHandler->bulkIndex(
139
                $contentObjects,
140
                function (Content $content, NotFoundException $e) use ($output, $progress) {
141
                    $this->logWarning($output, $progress, 'Content with id ' . $content->versionInfo->id . ' has missing data, so skipped for indexing. Full exception: ' . $e->getMessage()
142
                    );
143
                }
144
            );
145
146
            $progress->advance($k);
147
        } while (($i += $bulkCount) < $totalCount);
148
149
        $progress->finish();
150
    }