mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
FIX #108 for SS 3.x - Update and simplify getDirtyIDs method
This commit is contained in:
parent
5c38b0abce
commit
82d0bb4efe
@ -598,16 +598,14 @@ abstract class SearchIndex extends ViewableData
|
|||||||
|
|
||||||
foreach ($derivation['chain'] as $step) {
|
foreach ($derivation['chain'] as $step) {
|
||||||
if ($step['through'] == 'has_one') {
|
if ($step['through'] == 'has_one') {
|
||||||
$sql = new SQLQuery('"ID"', '"'.$step['class'].'"', '"'.$step['foreignkey'].'" IN ('.implode(',', $ids).')');
|
$ids = DataObject::get($step['class'])
|
||||||
singleton($step['class'])->extend('augmentSQL', $sql);
|
->filter($step['foreignkey'], $ids)
|
||||||
|
->column('ID');
|
||||||
$ids = $sql->execute()->column();
|
|
||||||
} elseif ($step['through'] == 'has_many') {
|
} elseif ($step['through'] == 'has_many') {
|
||||||
$sql = new SQLQuery('"'.$step['class'].'"."ID"', '"'.$step['class'].'"', '"'.$step['otherclass'].'"."ID" IN ('.implode(',', $ids).')');
|
// foreignkey identifies a has_one column on the model linked via the has_many relation
|
||||||
$sql->addInnerJoin($step['otherclass'], '"'.$step['class'].'"."ID" = "'.$step['otherclass'].'"."'.$step['foreignkey'].'"');
|
$ids = DataObject::get($step['otherclass'])
|
||||||
singleton($step['class'])->extend('augmentSQL', $sql);
|
->filter('ID', $ids)
|
||||||
|
->column($step['foreignkey']);
|
||||||
$ids = $sql->execute()->column();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($ids)) {
|
if (empty($ids)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user