Skip to content

Commit

Permalink
Fix #143 unsetting ShowInSearch not removing object from Index (#145)
Browse files Browse the repository at this point in the history
* Fix unsetting ShowInSearch not removing object from Index

* PHP CS Fixes

* Thinking is hard
  • Loading branch information
Firesphere authored and marczhermo committed Nov 28, 2019
1 parent 3f288e5 commit 6f24b82
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Extensions/DataObjectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ protected function pushToSolr(DataObject $owner)
try {
Versioned::set_reading_mode(Versioned::DEFAULT_MODE);
$service->setInDebugMode(false);
$service->updateItems(ArrayList::create([$owner]), SolrCoreService::UPDATE_TYPE);
$type = SolrCoreService::UPDATE_TYPE;
// If the object should not show in search, remove it
if ($owner->ShowInSearch === 0) {
$type = SolrCoreService::DELETE_TYPE;
}
$service->updateItems(ArrayList::create([$owner]), $type);
// If we don't get an exception, mark the item as clean
// Added bonus, array_flip removes duplicates
$this->clearIDs($owner, $ids, $record);
Expand Down

0 comments on commit 6f24b82

Please sign in to comment.