Skip to content

Commit

Permalink
[BUGFIX] DataHandler: Change uid type from int to string (kitodo#…
Browse files Browse the repository at this point in the history
…1080)

Signed-off-by: Christos Sidiropoulos <[email protected]>
Co-authored-by: Sebastian Meyer <[email protected]>
  • Loading branch information
csidirop and sebastian-meyer authored Nov 5, 2023
1 parent e9a134c commit 4772880
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions Classes/Hooks/DataHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ protected function getDocumentRepository(): DocumentRepository
*
* @param string $status 'new' or 'update'
* @param string $table The destination table
* @param int $id The uid of the record
* @param int|string $id The uid of the record
* @param array &$fieldArray Array of field values
*
* @return void
*/
public function processDatamap_postProcessFieldArray(string $status, string $table, int $id, array &$fieldArray): void
public function processDatamap_postProcessFieldArray(string $status, string $table, $id, array &$fieldArray): void // TODO: Add type-hinting for $id when dropping support for PHP 7.
{
if ($status == 'new') {
switch ($table) {
Expand Down Expand Up @@ -151,7 +151,7 @@ public function processDatamap_postProcessFieldArray(string $status, string $tab
->select($table . '.is_listed AS is_listed')
->from($table)
->where(
$queryBuilder->expr()->eq($table . '.uid', intval($id)),
$queryBuilder->expr()->eq($table . '.uid', (int) $id),
Helper::whereExpression($table)
)
->setMaxResults(1)
Expand All @@ -176,7 +176,7 @@ public function processDatamap_postProcessFieldArray(string $status, string $tab
->select($table . '.index_autocomplete AS index_autocomplete')
->from($table)
->where(
$queryBuilder->expr()->eq($table . '.uid', intval($id)),
$queryBuilder->expr()->eq($table . '.uid', (int) $id),
Helper::whereExpression($table)
)
->setMaxResults(1)
Expand All @@ -199,12 +199,12 @@ public function processDatamap_postProcessFieldArray(string $status, string $tab
*
* @param string $status 'new' or 'update'
* @param string $table The destination table
* @param int $id The uid of the record
* @param int|string $id The uid of the record
* @param array &$fieldArray Array of field values
*
* @return void
*/
public function processDatamap_afterDatabaseOperations(string $status, string $table, int $id, array &$fieldArray): void
public function processDatamap_afterDatabaseOperations(string $status, string $table, $id, array &$fieldArray): void // TODO: Add type-hinting for $id when dropping support for PHP 7.
{
if ($status == 'update') {
switch ($table) {
Expand Down Expand Up @@ -238,7 +238,7 @@ public function processDatamap_afterDatabaseOperations(string $status, string $t
->where(
$queryBuilder->expr()->eq(
'tx_dlf_documents_join.uid',
intval($id)
(int) $id
)
)
->setMaxResults(1)
Expand All @@ -251,19 +251,19 @@ public function processDatamap_afterDatabaseOperations(string $status, string $t
if ($solr->ready) {
// Delete Solr document.
$updateQuery = $solr->service->createUpdate();
$updateQuery->addDeleteQuery('uid:' . $id);
$updateQuery->addDeleteQuery('uid:' . (int) $id);
$updateQuery->addCommit();
$solr->service->update($updateQuery);
}
} else {
// Reindex document.
$document = $this->getDocumentRepository()->findByUid($id);
$document = $this->getDocumentRepository()->findByUid((int) $id);
$doc = AbstractDocument::getInstance($document->getLocation(), ['storagePid' => $document->getPid()], true);
if ($document !== null && $doc !== null) {
$document->setCurrentDocument($doc);
Indexer::add($document, $this->getDocumentRepository());
} else {
$this->logger->error('Failed to re-index document with UID ' . $id);
$this->logger->error('Failed to re-index document with UID ' . (string) $id);
}
}
}
Expand All @@ -280,11 +280,11 @@ public function processDatamap_afterDatabaseOperations(string $status, string $t
*
* @param string $command 'move', 'copy', 'localize', 'inlineLocalizeSynchronize', 'delete' or 'undelete'
* @param string $table The destination table
* @param int $id The uid of the record
* @param int|string $id The uid of the record
*
* @return void
*/
public function processCmdmap_postProcess(string $command, string $table, int $id): void
public function processCmdmap_postProcess(string $command, string $table, $id): void // TODO: Add type-hinting for $id when dropping support for PHP 7.
{
if (
in_array($command, ['move', 'delete', 'undelete'])
Expand Down Expand Up @@ -315,7 +315,7 @@ public function processCmdmap_postProcess(string $command, string $table, int $i
->where(
$queryBuilder->expr()->eq(
'tx_dlf_documents_join.uid',
intval($id)
(int) $id
)
)
->setMaxResults(1)
Expand All @@ -330,7 +330,7 @@ public function processCmdmap_postProcess(string $command, string $table, int $i
if ($solr->ready) {
// Delete Solr document.
$updateQuery = $solr->service->createUpdate();
$updateQuery->addDeleteQuery('uid:' . $id);
$updateQuery->addDeleteQuery('uid:' . (int) $id);
$updateQuery->addCommit();
$solr->service->update($updateQuery);
if ($command == 'delete') {
Expand All @@ -339,13 +339,13 @@ public function processCmdmap_postProcess(string $command, string $table, int $i
}
case 'undelete':
// Reindex document.
$document = $this->getDocumentRepository()->findByUid($id);
$document = $this->getDocumentRepository()->findByUid((int) $id);
$doc = AbstractDocument::getInstance($document->getLocation(), ['storagePid' => $document->getPid()], true);
if ($document !== null && $doc !== null) {
$document->setCurrentDocument($doc);
Indexer::add($document, $this->getDocumentRepository());
} else {
$this->logger->error('Failed to re-index document with UID ' . $id);
$this->logger->error('Failed to re-index document with UID ' . (string) $id);
}
break;
}
Expand All @@ -371,7 +371,7 @@ public function processCmdmap_postProcess(string $command, string $table, int $i
'tx_dlf_solrcores.index_name AS core'
)
->from('tx_dlf_solrcores')
->where($queryBuilder->expr()->eq('tx_dlf_solrcores.uid', intval($id)))
->where($queryBuilder->expr()->eq('tx_dlf_solrcores.uid', (int) $id))
->setMaxResults(1)
->execute();

Expand Down

0 comments on commit 4772880

Please sign in to comment.